Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-03-19 02:19:21
Exec Total Coverage
Lines: 1780 4266 41.7%
Functions: 128 343 37.3%
Branches: 953 2692 35.4%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include <fmt/format.h>
67
68 #ifdef __EMSCRIPTEN__
69 #include "base/emscripten_utils.h"
70 #endif
71
72 extern FFScript FFCore;
73 extern bool Playing;
74 int32_t sfx_voice[WAV_COUNT];
75 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
76 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
77
78 extern byte monochrome_console;
79
80 extern FONT *lfont;
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108 int32_t getnumber(const char *prompt,int32_t initialval);
109
110 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
111 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
112 //extern byte refresh_select_screen;
113 //extern movingblock mblock2; //mblock[4]?
114 //extern int32_t db;
115
116 static const char *ZC_str = "Zelda Classic";
117 extern char save_file_name[1024];
118 #ifdef ALLEGRO_DOS
119 const char *qst_dir_name = "dos_qst_dir";
120 #elif defined(ALLEGRO_WINDOWS)
121 const char *qst_dir_name = "win_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(ALLEGRO_LINUX)
124 const char *qst_dir_name = "linux_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #elif defined(__APPLE__)
127 const char *qst_dir_name = "osx_qst_dir";
128 static const char *qst_module_name = "current_module";
129 #endif
130 #ifdef ALLEGRO_LINUX
131 static const char *samplepath = "samplesoundset/patches.dat";
132 #endif
133 char qst_files_path[2048];
134
135 #ifdef _MSC_VER
136 #define getcwd _getcwd
137 #endif
138
139 bool rF11();
140 bool rI();
141 bool rQ();
142 bool zc_key_pressed();
143
144 #ifdef _WIN32
145
146 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
147 extern "C"
148 {
149 typedef HRESULT(WINAPI *t_DwmFlush)();
150 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
151 }
152
153 void do_DwmFlush()
154 {
155 static HMODULE shell = LoadLibrary("dwmapi.dll");
156
157 if(!shell)
158 return;
159
160 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
161 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
162
163 BOOL enabled;
164 isEnabled(&enabled);
165
166 if(isEnabled)
167 flush();
168 }
169
170 #endif // _WIN32
171
172 82019 bool flash_reduction_enabled(bool check_qr)
173 {
174
4/4
✓ Branch 0 taken 79798 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79342 times.
✓ Branch 3 taken 81563 times.
82019 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
175 }
176
177 // Dialogue largening
178 void large_dialog(DIALOG *d)
179 {
180 large_dialog(d, 1.5);
181 }
182
183 void large_dialog(DIALOG *d, float RESIZE_AMT)
184 {
185 if(!d[0].d1)
186 {
187 d[0].d1 = 1;
188 int32_t oldwidth = d[0].w;
189 int32_t oldheight = d[0].h;
190 int32_t oldx = d[0].x;
191 int32_t oldy = d[0].y;
192 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
193 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
194 d[0].w = int32_t(d[0].w*RESIZE_AMT);
195 d[0].h = int32_t(d[0].h*RESIZE_AMT);
196
197 for(int32_t i=1; d[i].proc !=NULL; i++)
198 {
199 // Place elements horizontally
200 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
201 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
202
203 if(d[i].proc != d_stringloader)
204 {
205 if(d[i].proc==d_bitmap_proc)
206 {
207 d[i].w *= 2;
208 }
209 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
210 }
211
212 // Place elements vertically
213 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
214 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
215
216 // Vertically resize elements
217 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
218 {
219 d[i].h = int32_t((double)d[i].h*1.5);
220 }
221 else if(d[i].proc == jwin_droplist_proc)
222 {
223 d[i].y += int32_t((double)d[i].h*0.25);
224 d[i].h = int32_t((double)d[i].h*1.25);
225 }
226 else if(d[i].proc==d_bitmap_proc)
227 {
228 d[i].h *= 2;
229 }
230 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
231
232 // Fix frames
233 if(d[i].proc == jwin_frame_proc)
234 {
235 d[i].x++;
236 d[i].y++;
237 d[i].w-=4;
238 d[i].h-=4;
239 }
240 }
241 }
242
243 for(int32_t i=1; d[i].proc!=NULL; i++)
244 {
245 if(d[i].proc==jwin_slider_proc)
246 continue;
247
248 // Bigger font
249 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
250
251 if(!d[i].dp2 && bigfontproc)
252 {
253 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
254 d[i].dp2 = lfont_l;
255 }
256 else if(!bigfontproc)
257 {
258 // ((ListData *)d[i].dp)->font = &sfont3;
259 ((ListData *)d[i].dp)->font = &lfont_l;
260 }
261
262 // Make checkboxes work
263 if(d[i].proc == jwin_check_proc)
264 d[i].proc = jwin_checkfont_proc;
265 else if(d[i].proc == jwin_radio_proc)
266 d[i].proc = jwin_radiofont_proc;
267 }
268
269 jwin_center_dialog(d);
270 }
271
272
273 /**********************************/
274 /******** System functions ********/
275 /**********************************/
276
277 static char cfg_sect[] = "zeldadx"; //We need to rename this.
278 static char ctrl_sect[] = "Controls";
279 static char sfx_sect[] = "Volume";
280
281 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
282 {
283 return D_O_K;
284 }
285
286 bool checkcheat(Cheat cheat)
287 {
288 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
289 return true; //Main key pressed
290 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
291 return true; //Alt key pressed
292 return false;
293 }
294 29 void load_default_cheatkeys()
295 {
296 29 memset(cheatkeys, 0, sizeof(cheatkeys));
297 29 cheatkeys[Cheat::Life][0] = KEY_H;
298 29 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
299 29 cheatkeys[Cheat::Magic][0] = KEY_M;
300 29 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
301 29 cheatkeys[Cheat::Rupies][0] = KEY_R;
302 29 cheatkeys[Cheat::Bombs][0] = KEY_B;
303 29 cheatkeys[Cheat::Arrows][0] = KEY_A;
304 29 cheatkeys[Cheat::Clock][0] = KEY_I;
305 29 cheatkeys[Cheat::Walls][0] = KEY_F11;
306 29 cheatkeys[Cheat::Fast][0] = KEY_Q;
307 29 cheatkeys[Cheat::Light][0] = KEY_L;
308 29 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
309 29 cheatkeys[Cheat::Kill][0] = KEY_K;
310 29 cheatkeys[Cheat::GoTo][0] = KEY_G;
311 29 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
312 29 cheatkeys[Cheat::ShowL0][0] = KEY_0;
313 29 cheatkeys[Cheat::ShowL1][0] = KEY_1;
314 29 cheatkeys[Cheat::ShowL2][0] = KEY_2;
315 29 cheatkeys[Cheat::ShowL3][0] = KEY_3;
316 29 cheatkeys[Cheat::ShowL4][0] = KEY_4;
317 29 cheatkeys[Cheat::ShowL5][0] = KEY_5;
318 29 cheatkeys[Cheat::ShowL6][0] = KEY_6;
319 29 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
320 29 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
321 29 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
322 29 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
323 29 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
324 29 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
325 29 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
326 29 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
327 29 }
328 29 void load_game_configs()
329 {
330 29 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
331 29 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
332 29 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
333 29 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
334 29 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
335 29 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
336 29 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
337 29 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
338 29 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
339 29 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
340 29 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
341 29 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
342 29 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
343 29 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
344 29 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
345
346 //cheat modifier keya
347 29 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
348 29 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
349 29 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
350 29 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
351
352 //cheat keys
353 29 load_default_cheatkeys();
354 char buf[256];
355 29 al_trace("START CHEATS\n");
356
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 29 times.
1044 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(!bindable_cheat((Cheat)q)) continue;
359 1015 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 util::lowerstr(cheatname);
361 1015 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][0]);
363
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
364 1015 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
365
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][1]);
366
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
367 1015 }
368 29 al_trace("END CHEATS\n");
369
370
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
371 joystick_index = 0;
372
373 29 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
374 29 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
375 29 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
376 29 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
377 29 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
378 29 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
379 29 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
380 29 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
381 29 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
382 29 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
383
384 29 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
385 29 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
386 29 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
387 29 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
388
389 29 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
390 29 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
391 29 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
392 29 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
393 29 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
394 29 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
395 29 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
396 29 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
397 29 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
398 29 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
399 29 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
400
401 29 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
402 29 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
403 29 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
404 29 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
405
406 29 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
407
408 29 digi_volume = zc_get_config(sfx_sect,"digi",248);
409 29 midi_volume = zc_get_config(sfx_sect,"midi",255);
410 29 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
411 29 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
412 29 pan_style = zc_get_config(sfx_sect,"pan",1);
413 // 1 <= zcmusic_bufsz <= 128
414 29 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
415 29 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
416 29 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
417 29 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
418 29 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
419 29 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
420 29 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
421 #ifdef __EMSCRIPTEN__
422 if (em_is_mobile()) NameEntryMode = 2;
423 #endif
424 29 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
425 29 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
426 29 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
427 29 title_version = zc_get_config(cfg_sect,"title",2);
428 29 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
429 29 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
430
431 //default - scale x2, 640 x 480
432 29 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
433 29 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
434 29 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
435 29 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
436 29 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
437 29 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
438
439 29 loadlast = zc_get_config(cfg_sect,"load_last",0);
440
441 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
442
443 29 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
444
445 29 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
446 29 info_opacity = zc_get_config("zc","debug_info_opacity",255);
447 #ifdef _WIN32
448 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
449 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
450 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
451 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
452
453 // This one's for Aero
454 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
455
456 // And this one fixes patches unloading on some MIDI setups
457 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
458 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
459 #else //UNIX
460 29 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
461 29 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
462 29 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
463 #endif
464 29 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
465 29 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
466
467 29 char const* default_path = "";
468 29 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
469
470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(strlen(qstdir)==0)
471 {
472 29 getcwd(qstdir,2048);
473 29 fix_filename_case(qstdir);
474 29 fix_filename_slashes(qstdir);
475 29 put_backslash(qstdir);
476 29 }
477 else
478 {
479 chop_path(qstdir);
480 }
481
482 29 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
483 29 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
484 29 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
485 29 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
486 29 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
487 29 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
488 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
489 29 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
490 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
491 29 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
492 29 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
493 29 }
494
495 void save_control_configs(bool kb)
496 {
497 if(kb)
498 {
499 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
500 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
501 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
502 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
503
504 if (!replay_is_replaying())
505 {
506 zc_set_config(ctrl_sect,"key_a",Akey);
507 zc_set_config(ctrl_sect,"key_b",Bkey);
508 zc_set_config(ctrl_sect,"key_s",Skey);
509 zc_set_config(ctrl_sect,"key_l",Lkey);
510 zc_set_config(ctrl_sect,"key_r",Rkey);
511 zc_set_config(ctrl_sect,"key_p",Pkey);
512 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
513 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
514 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
515 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
516 zc_set_config(ctrl_sect,"key_up", DUkey);
517 zc_set_config(ctrl_sect,"key_down", DDkey);
518 zc_set_config(ctrl_sect,"key_left", DLkey);
519 zc_set_config(ctrl_sect,"key_right",DRkey);
520 }
521 }
522 else
523 {
524 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
525 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
526 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
527 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
528 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
529 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
530 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
531 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
532 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
533 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
534 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
535 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
536 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
537 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
538
539 zc_set_config(ctrl_sect,"btn_a",Abtn);
540 zc_set_config(ctrl_sect,"btn_b",Bbtn);
541 zc_set_config(ctrl_sect,"btn_s",Sbtn);
542 zc_set_config(ctrl_sect,"btn_m",Mbtn);
543 zc_set_config(ctrl_sect,"btn_l",Lbtn);
544 zc_set_config(ctrl_sect,"btn_r",Rbtn);
545 zc_set_config(ctrl_sect,"btn_p",Pbtn);
546 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
547 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
548 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
549 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
550
551 zc_set_config(ctrl_sect,"btn_up",DUbtn);
552 zc_set_config(ctrl_sect,"btn_down",DDbtn);
553 zc_set_config(ctrl_sect,"btn_left",DLbtn);
554 zc_set_config(ctrl_sect,"btn_right",DRbtn);
555 }
556 }
557
558 void save_cheatkeys()
559 {
560 char buf[256];
561 for(size_t q = 1; q < Cheat::Last; ++q)
562 {
563 if(!bindable_cheat((Cheat)q)) continue;
564 std::string cheatname = cheat_to_string((Cheat)q);
565 util::lowerstr(cheatname);
566 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
567 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
568 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
569 if(cheatkeys[q][1])
570 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
571 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
572 }
573 }
574
575 void save_game_configs()
576 {
577 packfile_password("");
578
579 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
580
581 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
582 {
583 int o_window_x, o_window_y;
584 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
585 zc_set_config(cfg_sect,"window_x",o_window_x);
586 zc_set_config(cfg_sect,"window_y",o_window_y);
587 }
588
589 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
590 {
591 double monitor_scale = zc_get_monitor_scale();
592 window_width = al_get_display_width(all_get_display()) / monitor_scale;
593 window_height = al_get_display_height(all_get_display()) / monitor_scale;
594 zc_set_config(cfg_sect,"window_width",window_width);
595 zc_set_config(cfg_sect,"window_height",window_height);
596 }
597
598 zc_set_config(cfg_sect,"load_last",loadlast);
599 chop_path(qstdir);
600 zc_set_config(cfg_sect,qst_dir_name,qstdir);
601 zc_set_config("SAVEFILE","save_filename",save_file_name);
602 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
603
604 flush_config_file();
605 #ifdef __EMSCRIPTEN__
606 em_sync_fs();
607 #endif
608 }
609
610 //----------------------------------------------------------------
611
612 // Timers
613
614 30337 void fps_callback()
615 {
616 30337 lastfps=framecnt;
617 30337 dword tempsecs = fps_secs;
618 30337 ++tempsecs;
619 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
620 30337 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
621 30337 ++fps_secs;
622 30337 framecnt=0;
623 30337 }
624
625 END_OF_FUNCTION(fps_callback)
626
627 29 int32_t Z_init_timers()
628 {
629 static bool didit = false;
630 const static char *err_str = "Couldn't allocate timer";
631 29 err_str = err_str; //Unused variable warning
632
633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(didit)
634 return 1;
635
636 29 didit = true;
637
638 LOCK_VARIABLE(lastfps);
639 LOCK_VARIABLE(framecnt);
640 LOCK_FUNCTION(fps_callback);
641
642
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
643 return 0;
644
645 29 return 1;
646 29 }
647
648 void Z_remove_timers()
649 {
650 remove_int(fps_callback);
651 }
652
653 //----------------------------------------------------------------
654
655 void go()
656 {
657 scare_mouse();
658 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
659 unscare_mouse();
660 }
661
662 void comeback()
663 {
664 scare_mouse();
665 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
666 unscare_mouse();
667 }
668
669 void dump_pal(BITMAP *dest)
670 {
671 for(int32_t i=0; i<256; i++)
672 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
673 }
674
675 //----------------------------------------------------------------
676
677 //Handles converting the mouse sprite from the .dat file
678 29 void load_mouse()
679 {
680 29 system_pal();
681 29 scare_mouse();
682 29 set_mouse_sprite(NULL);
683 29 int32_t sz = vbound(int32_t(16*(zc_get_config("zeldadx","cursor_scale_large",1.5))),16,80);
684
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t j = 0; j < 4; ++j)
685 {
686 116 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
687 116 BITMAP* subbmp = create_bitmap_ex(8,16,16);
688
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(zcmouse[j])
689 destroy_bitmap(zcmouse[j]);
690 116 zcmouse[j] = create_bitmap_ex(8,sz,sz);
691 116 clear_bitmap(zcmouse[j]);
692 116 clear_bitmap(tmpbmp);
693 116 clear_bitmap(subbmp);
694 116 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
695
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 116 times.
1972 for(int32_t x = 0; x < 16; ++x)
696 {
697
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 1856 times.
31552 for(int32_t y = 0; y < 16; ++y)
698 {
699 29696 int32_t color = getpixel(tmpbmp, x, y);
700
5/5
✓ Branch 0 taken 27318 times.
✓ Branch 1 taken 551 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 522 times.
29696 switch(color)
701 {
702 case dvc(1):
703 551 color = jwin_pal[jcCURSORMISC];
704 551 break;
705 case dvc(2):
706 638 color = jwin_pal[jcCURSOROUTLINE];
707 638 break;
708 case dvc(3):
709 667 color = jwin_pal[jcCURSORLIGHT];
710 667 break;
711 case dvc(5):
712 522 color = jwin_pal[jcCURSORDARK];
713 522 break;
714 }
715 29696 putpixel(subbmp, x, y, color);
716 29696 }
717 1856 }
718
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(sz!=16)
719 116 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
720 else
721 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
722 116 destroy_bitmap(tmpbmp);
723 116 destroy_bitmap(subbmp);
724 116 }
725 29 set_mouse_sprite(zcmouse[0]);
726
727 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
728 29 set_palette(*hw_palette);
729 29 show_mouse(screen);
730 29 show_mouse(NULL);
731
732 29 unscare_mouse();
733 29 game_pal();
734 29 }
735
736 // sets the video mode and initializes the palette and mouse sprite
737 29 bool game_vid_mode(int32_t mode,int32_t wait)
738 {
739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
740 {
741 return false;
742 }
743
744 29 scrx = (resx-320)>>1;
745 29 scry = (resy-240)>>1;
746
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
747 116 zcmouse[q] = NULL;
748 29 load_mouse();
749 29 set_mouse_sprite(zcmouse[0]);
750
751
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 29 times.
493 for(int32_t i=240; i<256; i++)
752 464 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
753
754 29 set_palette(RAMpal);
755 29 clear_to_color(screen,BLACK);
756
757 29 rest(wait);
758 29 return true;
759 29 }
760
761 5 void null_quest()
762 {
763 char qstdat_string[2048];
764 5 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
765 5 strcat(qstdat_string,"#NESQST_NEW_QST");
766
767 #ifdef __EMSCRIPTEN__
768 // The quest template data file is not included because it's really big and isn't really needed
769 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
770 // which is much smaller.
771 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
772 #endif
773
774 5 byte skip_flags[4] = { 0 };
775
776 5 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
777 5 }
778
779 5 void init_NES_mode()
780 {
781 /*
782 // qst.dat may not load correctly without this...
783 QHeader.templatepath[0]='\0';
784
785 if(!init_colordata(true, &QHeader, &QMisc))
786 {
787 return;
788 }
789
790 loadfullpal();
791 init_tiles(false, &QHeader);
792 */
793 5 null_quest();
794 5 }
795
796 //----------------------------------------------------------------
797
798 qword trianglelines[16]=
799 {
800 0x0000000000000000ULL,
801 0xFD00000000000000ULL,
802 0xFDFD000000000000ULL,
803 0xFDFDFD0000000000ULL,
804 0xFDFDFDFD00000000ULL,
805 0xFDFDFDFDFD000000ULL,
806 0xFDFDFDFDFDFD0000ULL,
807 0xFDFDFDFDFDFDFD00ULL,
808 0xFDFDFDFDFDFDFDFDULL,
809 0x00FDFDFDFDFDFDFDULL,
810 0x0000FDFDFDFDFDFDULL,
811 0x000000FDFDFDFDFDULL,
812 0x00000000FDFDFDFDULL,
813 0x0000000000FDFDFDULL,
814 0x000000000000FDFDULL,
815 0x00000000000000FDULL,
816 };
817
818 word screen_triangles[28][32];
819 /*
820 qword triangles[4][16]= //[direction][value]
821 {
822 {
823 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
824 },
825 {
826 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
827 },
828 {
829 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
830 },
831 {
832 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
833 }
834 };
835 */
836
837
838 /*
839 byte triangles[4][16][8]= //[direction][value][line]
840 {
841 {
842 {
843 0, 0, 0, 0, 0, 0, 0, 0
844 },
845 {
846 1, 0, 0, 0, 0, 0, 0, 0
847 },
848 {
849 2, 1, 0, 0, 0, 0, 0, 0
850 },
851 {
852 3, 2, 1, 0, 0, 0, 0, 0
853 },
854 {
855 4, 3, 2, 1, 0, 0, 0, 0
856 },
857 {
858 5, 4, 3, 2, 1, 0, 0, 0
859 },
860 {
861 6, 5, 4, 3, 2, 1, 0, 0
862 },
863 {
864 7, 6, 5, 4, 3, 2, 1, 0
865 },
866 {
867 8, 7, 6, 5, 4, 3, 2, 1
868 },
869 {
870 8, 8, 7, 6, 5, 4, 3, 2
871 },
872 {
873 8, 8, 8, 7, 6, 5, 4, 3
874 },
875 {
876 8, 8, 8, 8, 7, 6, 5, 4
877 },
878 {
879 8, 8, 8, 8, 8, 7, 6, 5
880 },
881 {
882 8, 8, 8, 8, 8, 8, 7, 6
883 },
884 {
885 8, 8, 8, 8, 8, 8, 8, 7
886 },
887 {
888 8, 8, 8, 8, 8, 8, 8, 8
889 }
890 },
891 {
892 {
893 0, 0, 0, 0, 0, 0, 0, 0
894 },
895 {
896 15, 0, 0, 0, 0, 0, 0, 0
897 },
898 {
899 14, 15, 0, 0, 0, 0, 0, 0
900 },
901 {
902 13, 14, 15, 0, 0, 0, 0, 0
903 },
904 {
905 12, 13, 14, 15, 0, 0, 0, 0
906 },
907 {
908 11, 12, 13, 14, 15, 0, 0, 0
909 },
910 {
911 10, 11, 12, 13, 14, 15, 0, 0
912 },
913 {
914 9, 10, 11, 12, 13, 14, 15, 0
915 },
916 {
917 8, 9, 10, 11, 12, 13, 14, 15
918 },
919 {
920 8, 8, 9, 10, 11, 12, 13, 14
921 },
922 {
923 8, 8, 8, 9, 10, 11, 12, 13
924 },
925 {
926 8, 8, 8, 8, 9, 10, 11, 12
927 },
928 {
929 8, 8, 8, 8, 8, 9, 10, 11
930 },
931 {
932 8, 8, 8, 8, 8, 8, 9, 10
933 },
934 {
935 8, 8, 8, 8, 8, 8, 8, 9
936 },
937 {
938 8, 8, 8, 8, 8, 8, 8, 8
939 }
940 },
941 {
942 {
943 0, 0, 0, 0, 0, 0, 0, 0
944 },
945 {
946 0, 0, 0, 0, 0, 0, 0, 1
947 },
948 {
949 0, 0, 0, 0, 0, 0, 1, 2
950 },
951 {
952 0, 0, 0, 0, 0, 1, 2, 3
953 },
954 {
955 0, 0, 0, 0, 1, 2, 3, 4
956 },
957 {
958 0, 0, 0, 1, 2, 3, 4, 5
959 },
960 {
961 0, 0, 1, 2, 3, 4, 5, 6
962 },
963 {
964 0, 1, 2, 3, 4, 5, 6, 7
965 },
966 {
967 1, 2, 3, 4, 5, 6, 7, 8
968 },
969 {
970 2, 3, 4, 5, 6, 7, 8, 8
971 },
972 {
973 3, 4, 5, 6, 7, 8, 8, 8
974 },
975 {
976 4, 5, 6, 7, 8, 8, 8, 8
977 },
978 {
979 5, 6, 7, 8, 8, 8, 8, 8
980 },
981 {
982 6, 7, 8, 8, 8, 8, 8, 8
983 },
984 {
985 7, 8, 8, 8, 8, 8, 8, 8
986 },
987 {
988 8, 8, 8, 8, 8, 8, 8, 8
989 }
990 },
991 {
992 {
993 0, 0, 0, 0, 0, 0, 0, 0
994 },
995 {
996 0, 0, 0, 0, 0, 0, 0, 15
997 },
998 {
999 0, 0, 0, 0, 0, 0, 15, 14
1000 },
1001 {
1002 0, 0, 0, 0, 0, 15, 14, 13
1003 },
1004 {
1005 0, 0, 0, 0, 15, 14, 13, 12
1006 },
1007 {
1008 0, 0, 0, 15, 14, 13, 12, 11
1009 },
1010 {
1011 0, 0, 15, 14, 13, 12, 11, 10
1012 },
1013 {
1014 0, 15, 14, 13, 12, 11, 10, 9
1015 },
1016 {
1017 15, 14, 13, 12, 11, 10, 9, 8
1018 },
1019 {
1020 14, 13, 12, 11, 10, 9, 8, 8
1021 },
1022 {
1023 13, 12, 11, 10, 9, 8, 8, 8
1024 },
1025 {
1026 12, 11, 10, 9, 8, 8, 8, 8
1027 },
1028 {
1029 11, 10, 9, 8, 8, 8, 8, 8
1030 },
1031 {
1032 10, 9, 8, 8, 8, 8, 8, 8
1033 },
1034 {
1035 9, 8, 8, 8, 8, 8, 8, 8
1036 },
1037 {
1038 8, 8, 8, 8, 8, 8, 8, 8
1039 }
1040 }
1041 };
1042 */
1043
1044
1045
1046 /*
1047 for (int32_t blockrow=0; blockrow<30; ++i)
1048 {
1049 for (int32_t linerow=0; linerow<8; ++i)
1050 {
1051 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1052 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1053 {
1054 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1055 ++triangleline;
1056 }
1057 }
1058 }
1059 */
1060
1061 // the ULL suffixes are to prevent this warning:
1062 // warning: integer constant is too large for "int32_t" type
1063
1064 qword triangles[4][16][8]= //[direction][value][line]
1065 {
1066 {
1067 {
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL
1076 },
1077 {
1078 0xFD00000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL
1086 },
1087 {
1088 0xFDFD000000000000ULL,
1089 0xFD00000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL
1096 },
1097 {
1098 0xFDFDFD0000000000ULL,
1099 0xFDFD000000000000ULL,
1100 0xFD00000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL
1106 },
1107 {
1108 0xFDFDFDFD00000000ULL,
1109 0xFDFDFD0000000000ULL,
1110 0xFDFD000000000000ULL,
1111 0xFD00000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL
1116 },
1117 {
1118 0xFDFDFDFDFD000000ULL,
1119 0xFDFDFDFD00000000ULL,
1120 0xFDFDFD0000000000ULL,
1121 0xFDFD000000000000ULL,
1122 0xFD00000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL
1126 },
1127 {
1128 0xFDFDFDFDFDFD0000ULL,
1129 0xFDFDFDFDFD000000ULL,
1130 0xFDFDFDFD00000000ULL,
1131 0xFDFDFD0000000000ULL,
1132 0xFDFD000000000000ULL,
1133 0xFD00000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL
1136 },
1137 {
1138 0xFDFDFDFDFDFDFD00ULL,
1139 0xFDFDFDFDFDFD0000ULL,
1140 0xFDFDFDFDFD000000ULL,
1141 0xFDFDFDFD00000000ULL,
1142 0xFDFDFD0000000000ULL,
1143 0xFDFD000000000000ULL,
1144 0xFD00000000000000ULL,
1145 0x0000000000000000ULL
1146 },
1147 {
1148 0xFDFDFDFDFDFDFDFDULL,
1149 0xFDFDFDFDFDFDFD00ULL,
1150 0xFDFDFDFDFDFD0000ULL,
1151 0xFDFDFDFDFD000000ULL,
1152 0xFDFDFDFD00000000ULL,
1153 0xFDFDFD0000000000ULL,
1154 0xFDFD000000000000ULL,
1155 0xFD00000000000000ULL
1156 },
1157 {
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFD00ULL,
1161 0xFDFDFDFDFDFD0000ULL,
1162 0xFDFDFDFDFD000000ULL,
1163 0xFDFDFDFD00000000ULL,
1164 0xFDFDFD0000000000ULL,
1165 0xFDFD000000000000ULL
1166 },
1167 {
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFD00ULL,
1172 0xFDFDFDFDFDFD0000ULL,
1173 0xFDFDFDFDFD000000ULL,
1174 0xFDFDFDFD00000000ULL,
1175 0xFDFDFD0000000000ULL
1176 },
1177 {
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFD00ULL,
1183 0xFDFDFDFDFDFD0000ULL,
1184 0xFDFDFDFDFD000000ULL,
1185 0xFDFDFDFD00000000ULL
1186 },
1187 {
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFD00ULL,
1194 0xFDFDFDFDFDFD0000ULL,
1195 0xFDFDFDFDFD000000ULL
1196 },
1197 {
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFD00ULL,
1205 0xFDFDFDFDFDFD0000ULL
1206 },
1207 {
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFD00ULL
1216 },
1217 {
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL
1226 }
1227 },
1228 {
1229 {
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL
1238 },
1239 {
1240 0x00000000000000FDULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL
1248 },
1249 {
1250 0x000000000000FDFDULL,
1251 0x00000000000000FDULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL
1258 },
1259 {
1260 0x0000000000FDFDFDULL,
1261 0x000000000000FDFDULL,
1262 0x00000000000000FDULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL
1268 },
1269 {
1270 0x00000000FDFDFDFDULL,
1271 0x0000000000FDFDFDULL,
1272 0x000000000000FDFDULL,
1273 0x00000000000000FDULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL
1278 },
1279 {
1280 0x000000FDFDFDFDFDULL,
1281 0x00000000FDFDFDFDULL,
1282 0x0000000000FDFDFDULL,
1283 0x000000000000FDFDULL,
1284 0x00000000000000FDULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL
1288 },
1289 {
1290 0x0000FDFDFDFDFDFDULL,
1291 0x000000FDFDFDFDFDULL,
1292 0x00000000FDFDFDFDULL,
1293 0x0000000000FDFDFDULL,
1294 0x000000000000FDFDULL,
1295 0x00000000000000FDULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL
1298 },
1299 {
1300 0x00FDFDFDFDFDFDFDULL,
1301 0x0000FDFDFDFDFDFDULL,
1302 0x000000FDFDFDFDFDULL,
1303 0x00000000FDFDFDFDULL,
1304 0x0000000000FDFDFDULL,
1305 0x000000000000FDFDULL,
1306 0x00000000000000FDULL,
1307 0x0000000000000000ULL
1308 },
1309 {
1310 0xFDFDFDFDFDFDFDFDULL,
1311 0x00FDFDFDFDFDFDFDULL,
1312 0x0000FDFDFDFDFDFDULL,
1313 0x000000FDFDFDFDFDULL,
1314 0x00000000FDFDFDFDULL,
1315 0x0000000000FDFDFDULL,
1316 0x000000000000FDFDULL,
1317 0x00000000000000FDULL
1318 },
1319 {
1320 0xFDFDFDFDFDFDFDFDULL,
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0x00FDFDFDFDFDFDFDULL,
1323 0x0000FDFDFDFDFDFDULL,
1324 0x000000FDFDFDFDFDULL,
1325 0x00000000FDFDFDFDULL,
1326 0x0000000000FDFDFDULL,
1327 0x000000000000FDFDULL
1328 },
1329 {
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0x00FDFDFDFDFDFDFDULL,
1334 0x0000FDFDFDFDFDFDULL,
1335 0x000000FDFDFDFDFDULL,
1336 0x00000000FDFDFDFDULL,
1337 0x0000000000FDFDFDULL
1338 },
1339 {
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0x00FDFDFDFDFDFDFDULL,
1345 0x0000FDFDFDFDFDFDULL,
1346 0x000000FDFDFDFDFDULL,
1347 0x00000000FDFDFDFDULL
1348 },
1349 {
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0x00FDFDFDFDFDFDFDULL,
1356 0x0000FDFDFDFDFDFDULL,
1357 0x000000FDFDFDFDFDULL
1358 },
1359 {
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0x00FDFDFDFDFDFDFDULL,
1367 0x0000FDFDFDFDFDFDULL
1368 },
1369 {
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0x00FDFDFDFDFDFDFDULL
1378 },
1379 {
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL
1388 }
1389 },
1390 {
1391 {
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL
1400 },
1401 {
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0xFD00000000000000ULL
1410 },
1411 {
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0xFD00000000000000ULL,
1419 0xFDFD000000000000ULL
1420 },
1421 {
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0xFD00000000000000ULL,
1428 0xFDFD000000000000ULL,
1429 0xFDFDFD0000000000ULL
1430 },
1431 {
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0xFD00000000000000ULL,
1437 0xFDFD000000000000ULL,
1438 0xFDFDFD0000000000ULL,
1439 0xFDFDFDFD00000000ULL
1440 },
1441 {
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0xFD00000000000000ULL,
1446 0xFDFD000000000000ULL,
1447 0xFDFDFD0000000000ULL,
1448 0xFDFDFDFD00000000ULL,
1449 0xFDFDFDFDFD000000ULL
1450 },
1451 {
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0xFD00000000000000ULL,
1455 0xFDFD000000000000ULL,
1456 0xFDFDFD0000000000ULL,
1457 0xFDFDFDFD00000000ULL,
1458 0xFDFDFDFDFD000000ULL,
1459 0xFDFDFDFDFDFD0000ULL
1460 },
1461 {
1462 0x0000000000000000ULL,
1463 0xFD00000000000000ULL,
1464 0xFDFD000000000000ULL,
1465 0xFDFDFD0000000000ULL,
1466 0xFDFDFDFD00000000ULL,
1467 0xFDFDFDFDFD000000ULL,
1468 0xFDFDFDFDFDFD0000ULL,
1469 0xFDFDFDFDFDFDFD00ULL
1470 },
1471 {
1472 0xFD00000000000000ULL,
1473 0xFDFD000000000000ULL,
1474 0xFDFDFD0000000000ULL,
1475 0xFDFDFDFD00000000ULL,
1476 0xFDFDFDFDFD000000ULL,
1477 0xFDFDFDFDFDFD0000ULL,
1478 0xFDFDFDFDFDFDFD00ULL,
1479 0xFDFDFDFDFDFDFDFDULL
1480 },
1481 {
1482 0xFDFD000000000000ULL,
1483 0xFDFDFD0000000000ULL,
1484 0xFDFDFDFD00000000ULL,
1485 0xFDFDFDFDFD000000ULL,
1486 0xFDFDFDFDFDFD0000ULL,
1487 0xFDFDFDFDFDFDFD00ULL,
1488 0xFDFDFDFDFDFDFDFDULL,
1489 0xFDFDFDFDFDFDFDFDULL
1490 },
1491 {
1492 0xFDFDFD0000000000ULL,
1493 0xFDFDFDFD00000000ULL,
1494 0xFDFDFDFDFD000000ULL,
1495 0xFDFDFDFDFDFD0000ULL,
1496 0xFDFDFDFDFDFDFD00ULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL,
1499 0xFDFDFDFDFDFDFDFDULL
1500 },
1501 {
1502 0xFDFDFDFD00000000ULL,
1503 0xFDFDFDFDFD000000ULL,
1504 0xFDFDFDFDFDFD0000ULL,
1505 0xFDFDFDFDFDFDFD00ULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL
1510 },
1511 {
1512 0xFDFDFDFDFD000000ULL,
1513 0xFDFDFDFDFDFD0000ULL,
1514 0xFDFDFDFDFDFDFD00ULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL
1520 },
1521 {
1522 0xFDFDFDFDFDFD0000ULL,
1523 0xFDFDFDFDFDFDFD00ULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL
1530 },
1531 {
1532 0xFDFDFDFDFDFDFD00ULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL
1540 },
1541 {
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL
1550 }
1551 },
1552 {
1553 {
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL
1562 },
1563 {
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x00000000000000FDULL
1572 },
1573 {
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x00000000000000FDULL,
1581 0x000000000000FDFDULL
1582 },
1583 {
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x00000000000000FDULL,
1590 0x000000000000FDFDULL,
1591 0x0000000000FDFDFDULL
1592 },
1593 {
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x00000000000000FDULL,
1599 0x000000000000FDFDULL,
1600 0x0000000000FDFDFDULL,
1601 0x00000000FDFDFDFDULL
1602 },
1603 {
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x00000000000000FDULL,
1608 0x000000000000FDFDULL,
1609 0x0000000000FDFDFDULL,
1610 0x00000000FDFDFDFDULL,
1611 0x000000FDFDFDFDFDULL
1612 },
1613 {
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x00000000000000FDULL,
1617 0x000000000000FDFDULL,
1618 0x0000000000FDFDFDULL,
1619 0x00000000FDFDFDFDULL,
1620 0x000000FDFDFDFDFDULL,
1621 0x0000FDFDFDFDFDFDULL
1622 },
1623 {
1624 0x0000000000000000ULL,
1625 0x00000000000000FDULL,
1626 0x000000000000FDFDULL,
1627 0x0000000000FDFDFDULL,
1628 0x00000000FDFDFDFDULL,
1629 0x000000FDFDFDFDFDULL,
1630 0x0000FDFDFDFDFDFDULL,
1631 0x00FDFDFDFDFDFDFDULL
1632 },
1633 {
1634 0x00000000000000FDULL,
1635 0x000000000000FDFDULL,
1636 0x0000000000FDFDFDULL,
1637 0x00000000FDFDFDFDULL,
1638 0x000000FDFDFDFDFDULL,
1639 0x0000FDFDFDFDFDFDULL,
1640 0x00FDFDFDFDFDFDFDULL,
1641 0xFDFDFDFDFDFDFDFDULL
1642 },
1643 {
1644 0x000000000000FDFDULL,
1645 0x0000000000FDFDFDULL,
1646 0x00000000FDFDFDFDULL,
1647 0x000000FDFDFDFDFDULL,
1648 0x0000FDFDFDFDFDFDULL,
1649 0x00FDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL,
1651 0xFDFDFDFDFDFDFDFDULL
1652 },
1653 {
1654 0x0000000000FDFDFDULL,
1655 0x00000000FDFDFDFDULL,
1656 0x000000FDFDFDFDFDULL,
1657 0x0000FDFDFDFDFDFDULL,
1658 0x00FDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL
1662 },
1663 {
1664 0x00000000FDFDFDFDULL,
1665 0x000000FDFDFDFDFDULL,
1666 0x0000FDFDFDFDFDFDULL,
1667 0x00FDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL
1672 },
1673 {
1674 0x000000FDFDFDFDFDULL,
1675 0x0000FDFDFDFDFDFDULL,
1676 0x00FDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL
1682 },
1683 {
1684 0x0000FDFDFDFDFDFDULL,
1685 0x00FDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL
1692 },
1693 {
1694 0x00FDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL
1702 },
1703 {
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL
1712 }
1713 }
1714 };
1715
1716 int32_t black_opening_count=0;
1717 int32_t black_opening_x,black_opening_y;
1718 int32_t black_opening_shape;
1719
1720 791 int32_t choose_opening_shape()
1721 {
1722 // First, count how many bits are set
1723 791 int32_t numBits=0;
1724 int32_t bitCounter;
1725
1726
2/2
✓ Branch 0 taken 3955 times.
✓ Branch 1 taken 791 times.
4746 for(int32_t i=0; i<bosMAX; i++)
1727 {
1728
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 1007 times.
3955 if(COOLSCROLL&(1<<i))
1729 1007 numBits++;
1730 3955 }
1731
1732 // Shouldn't happen...
1733
1/2
✓ Branch 0 taken 791 times.
✗ Branch 1 not taken.
791 if(numBits==0)
1734 return bosCIRCLE;
1735
1736 // Pick a bit
1737 791 bitCounter=zc_rand()%numBits+1;
1738
1739
2/2
✓ Branch 0 taken 1003 times.
✓ Branch 1 taken 26 times.
1029 for(int32_t i=0; i<bosMAX; i++)
1740 {
1741 // If this bit is set, decrement the bit counter
1742
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 921 times.
1003 if(COOLSCROLL&(1<<i))
1743 921 bitCounter--;
1744
1745 // When the counter hits 0, return a value based on
1746 // which bit it stopped on.
1747 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1748
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 238 times.
1003 if(bitCounter==0)
1749 765 return i;
1750 238 }
1751
1752 // Shouldn't be necessary, but the compiler might complain, at least
1753 26 return bosCIRCLE;
1754 791 }
1755
1756 216 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1757 {
1758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1759
1760 216 int32_t w=256, h=224;
1761 216 int32_t blockrows=28, blockcolumns=32;
1762 216 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1763
1764
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 216 times.
6264 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1765 {
1766
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 6048 times.
199584 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1767 {
1768
2/2
✓ Branch 0 taken 103944 times.
✓ Branch 1 taken 89592 times.
193536 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1769 193536 }
1770 6048 }
1771
1772 216 black_opening_count = 66;
1773 216 black_opening_x = x;
1774 216 black_opening_y = y;
1775 216 lensclk = 0;
1776 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1777
1778
1779
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(black_opening_shape == bosFADEBLACK)
1780 {
1781 refreshTints();
1782 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1783 }
1784
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(wait)
1785 {
1786 FFCore.warpScriptCheck();
1787 for(int32_t i=0; i<66; i++)
1788 {
1789 draw_screen(tmpscr);
1790 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1791 advanceframe(true);
1792
1793 if(Quit)
1794 {
1795 break;
1796 }
1797 }
1798 }
1799 216 }
1800
1801 575 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1802 {
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1804
1805 575 int32_t w=256, h=224;
1806 575 int32_t blockrows=28, blockcolumns=32;
1807 575 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1808
1809
2/2
✓ Branch 0 taken 16100 times.
✓ Branch 1 taken 575 times.
16675 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1810 {
1811
2/2
✓ Branch 0 taken 515200 times.
✓ Branch 1 taken 16100 times.
531300 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1812 {
1813
2/2
✓ Branch 0 taken 241603 times.
✓ Branch 1 taken 273597 times.
515200 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1814 515200 }
1815 16100 }
1816
1817 575 black_opening_count = -66;
1818 575 black_opening_x = x;
1819 575 black_opening_y = y;
1820 575 lensclk = 0;
1821
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(black_opening_shape == bosFADEBLACK)
1822 {
1823 refreshTints();
1824 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1825 }
1826
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 465 times.
575 if(wait)
1827 {
1828 465 FFCore.warpScriptCheck();
1829
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 30690 times.
31155 for(int32_t i=0; i<66; i++)
1830 {
1831 30690 draw_screen(tmpscr);
1832 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1833 30690 advanceframe(true);
1834
1835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30690 times.
30690 if(Quit)
1836 {
1837 break;
1838 }
1839 30690 }
1840 465 }
1841 575 }
1842
1843 52206 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1844 {
1845 52206 clear_to_color(tmp_scr,BLACK);
1846 52206 int32_t w=256, h=224;
1847
1848
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49038 times.
52206 switch(black_opening_shape)
1849 {
1850 case bosOVAL:
1851 {
1852 858 double new_w=(w/2)+abs(w/2-x);
1853 858 double new_h=(h/2)+abs(h/2-y);
1854 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1855 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1856 858 break;
1857 }
1858
1859 case bosTRIANGLE:
1860 {
1861 660 double new_w=(w/2)+abs(w/2-x);
1862 660 double new_h=(h/2)+abs(h/2-y);
1863 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1864 660 double P2= (PI/2);
1865 660 double P23=(2*PI/3);
1866 660 double P43=(4*PI/3);
1867 660 double Pa= (-4*PI*a/(3*max_a));
1868 660 double angle=P2+Pa;
1869 660 double a0=angle;
1870 660 double a2=angle+P23;
1871 660 double a4=angle+P43;
1872 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1873 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1874 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1875 0);
1876 660 break;
1877 }
1878
1879 case bosSMAS:
1880 {
1881
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1882
1883
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1884 {
1885
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1886 {
1887 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1888
1889
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1890 {
1891 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1892
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1893 11827200 [linerow];
1894 11827200 ++triangleline;
1895
1896
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1897 {
1898 1478400 }
1899 11827200 }
1900 369600 }
1901 46200 }
1902
1903 1650 break;
1904 }
1905
1906 case bosFADEBLACK:
1907 {
1908 if(black_opening_count<0)
1909 {
1910 black_fade(zc_min(-black_opening_count,63));
1911 }
1912 else if(black_opening_count>0)
1913 {
1914 black_fade(63-zc_max(black_opening_count-3,0));
1915 }
1916 else black_fade(0);
1917 return; //no blitting from tmp_scr!
1918 }
1919
1920 49038 case bosCIRCLE:
1921 default:
1922 {
1923 49038 double new_w=(w/2)+abs(w/2-x);
1924 49038 double new_h=(h/2)+abs(h/2-y);
1925 49038 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1926 //circlefill(tmp_scr,x,y,a<<3,0);
1927 49038 circlefill(tmp_scr,x,y,r,0);
1928 49038 break;
1929 }
1930 }
1931
1932 52206 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1933 52206 }
1934
1935
1936 void black_fade(int32_t fadeamnt)
1937 {
1938 for(int32_t i=0; i < 0xEF; i++)
1939 {
1940 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1941 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1942 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1943 }
1944
1945 refreshpal = true;
1946 }
1947
1948 //----------------------------------------------------------------
1949
1950 15952533 bool item_disabled(int32_t item) //is this item disabled?
1951 {
1952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15952533 times.
15952533 return (item>=0 && game->items_off[item] != 0);
1953 }
1954
1955 5426600 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1956 {
1957
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 5368758 times.
5426600 if(current_item(item_type, true) >=item)
1958 {
1959 57842 return true;
1960 }
1961
1962 5368758 return false;
1963 5426600 }
1964
1965 22449319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1966 {
1967
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2439977 times.
✓ Branch 6 taken 12012783 times.
✓ Branch 7 taken 3882589 times.
✓ Branch 8 taken 27624 times.
22449319 switch(item_type)
1968 {
1969 case itype_bomb:
1970 case itype_sbomb:
1971 {
1972 int32_t itemid = getItemID(itemsbuf, item_type, it);
1973
1974 if(itemid == -1)
1975 return false;
1976
1977 return (game->get_item(itemid));
1978 }
1979
1980 case itype_clock:
1981 {
1982 4086346 int32_t itemid = getItemID(itemsbuf, item_type, it);
1983
1984
2/4
✓ Branch 0 taken 4086346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
4086346 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1985 return (game->get_item(itemid));
1986 4086346 return Hero.getClock()?1:0;
1987 }
1988
1989 case itype_key:
1990 return (game->get_keys()>0);
1991
1992 case itype_magiccontainer:
1993 return (game->get_maxmagic()>=game->get_mp_per_block());
1994
1995 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1996 {
1997
1/3
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2439977 switch(it)
1998 {
1999 case -2:
2000 {
2001 for(int32_t i=0; i<MAXLEVELS; i++)
2002 {
2003 if(game->lvlitems[i]&liTRIFORCE)
2004 {
2005 return true;
2006 }
2007 }
2008
2009 return false;
2010 }
2011
2012 case -1:
2013 return (game->lvlitems[dlevel]&liTRIFORCE);
2014
2015 default:
2016
2/4
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2439977 times.
2439977 if(it>=0&&it<MAXLEVELS)
2017 {
2018 2439977 return (game->lvlitems[it]&liTRIFORCE);
2019 }
2020
2021 break;
2022 }
2023
2024 return 0;
2025 }
2026
2027 case itype_map: //it: -2=any, -1=current level, other=that level
2028 {
2029
1/3
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12012783 switch(it)
2030 {
2031 case -2:
2032 {
2033 for(int32_t i=0; i<MAXLEVELS; i++)
2034 {
2035 if(game->lvlitems[i]&liMAP)
2036 {
2037 return true;
2038 }
2039 }
2040
2041 return false;
2042 }
2043
2044 case -1:
2045 return (game->lvlitems[dlevel]&liMAP)!=0;
2046
2047 default:
2048
2/4
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12012783 times.
12012783 if(it>=0&&it<MAXLEVELS)
2049 {
2050 12012783 return (game->lvlitems[it]&liMAP)!=0;
2051 }
2052
2053 break;
2054 }
2055
2056 return 0;
2057 }
2058
2059 case itype_compass: //it: -2=any, -1=current level, other=that level
2060 {
2061
1/3
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3882589 switch(it)
2062 {
2063 case -2:
2064 {
2065 for(int32_t i=0; i<MAXLEVELS; i++)
2066 {
2067 if(game->lvlitems[i]&liCOMPASS)
2068 {
2069 return true;
2070 }
2071 }
2072
2073 return false;
2074 }
2075
2076 case -1:
2077 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2078
2079 default:
2080
2/4
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3882589 times.
✗ Branch 3 not taken.
3882589 if(it>=0&&it<MAXLEVELS)
2081 {
2082 3882589 return (game->lvlitems[it]&liCOMPASS)!=0;
2083 }
2084
2085 break;
2086 }
2087 return 0;
2088 }
2089
2090 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2091 {
2092
1/3
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
27624 switch(it)
2093 {
2094 case -2:
2095 {
2096 for(int32_t i=0; i<MAXLEVELS; i++)
2097 {
2098 if(game->lvlitems[i]&liBOSSKEY)
2099 {
2100 return true;
2101 }
2102 }
2103
2104 return false;
2105 }
2106
2107 case -1:
2108 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2109
2110 default:
2111
2/4
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27624 times.
27624 if(it>=0&&it<MAXLEVELS)
2112 {
2113 27624 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2114 }
2115 break;
2116 }
2117 return 0;
2118 }
2119
2120 default:
2121 //it=(1<<(it-1));
2122 /*if (item_type>=itype_max)
2123 {
2124 system_pal();
2125 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2126 game_pal();
2127
2128 return false;
2129 }*/
2130 int32_t itemid = getItemID(itemsbuf, item_type, it);
2131
2132 if(itemid == -1)
2133 return false;
2134
2135 return game->get_item(itemid);
2136 }
2137 22449319 }
2138
2139
2140 69865212 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2141 {
2142
9/9
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 37174444 times.
✓ Branch 2 taken 4086346 times.
✓ Branch 3 taken 4086346 times.
✓ Branch 4 taken 4086346 times.
✓ Branch 5 taken 4086346 times.
✓ Branch 6 taken 4086346 times.
✓ Branch 7 taken 4086346 times.
✓ Branch 8 taken 4086346 times.
69865212 switch(item_type)
2143 {
2144 case itype_clock:
2145 {
2146 4086346 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2147
2148
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4086346 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4086346 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2149 return itemsbuf[maxid].fam_type;
2150
2151 4086346 return has_item(itype_clock,1) ? 1 : 0;
2152 }
2153
2154 case itype_key:
2155 4086346 return game->get_keys();
2156
2157 case itype_lkey:
2158 4086346 return game->lvlkeys[get_dlevel()];
2159
2160 case itype_magiccontainer:
2161 4086346 return game->get_maxmagic()/game->get_mp_per_block();
2162
2163 case itype_triforcepiece:
2164 {
2165 4086346 int32_t count=0;
2166
2167
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2168 {
2169 2092209152 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2170 2092209152 }
2171
2172 4086346 return count;
2173 }
2174
2175 case itype_map:
2176 {
2177 4086346 int32_t count=0;
2178
2179
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2180 {
2181 2092209152 count+=(game->lvlitems[i]&liMAP)?1:0;
2182 2092209152 }
2183
2184 4086346 return count;
2185 }
2186
2187 case itype_compass:
2188 {
2189 4086346 int32_t count=0;
2190
2191
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2192 {
2193 2092209152 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2194 2092209152 }
2195
2196 4086346 return count;
2197 }
2198
2199 case itype_bosskey:
2200 {
2201 4086346 int32_t count=0;
2202
2203
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2204 {
2205 2092209152 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2206 2092209152 }
2207
2208 4086346 return count;
2209 }
2210
2211 default:
2212 37174444 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2213
2214
2/2
✓ Branch 0 taken 6971052 times.
✓ Branch 1 taken 30203392 times.
37174444 if(maxid == -1)
2215 30203392 return 0;
2216
2217 6971052 return itemsbuf[maxid].fam_type;
2218 }
2219 69865212 }
2220
2221 64438612 int32_t current_item(int32_t item_type) //item currently being used
2222 {
2223 64438612 return current_item(item_type, true);
2224 }
2225
2226 29 std::map<int32_t, int32_t> itemcache;
2227
2228 // Not actually used by anything at the moment...
2229 void removeFromItemCache(int32_t itemid)
2230 {
2231 itemcache.erase(itemid);
2232 }
2233
2234 19096 void flushItemCache()
2235 {
2236 19096 itemcache.clear();
2237
2238 //also fix the active subscreen if items were deleted -DD
2239
1/2
✓ Branch 0 taken 19096 times.
✗ Branch 1 not taken.
19096 if(game != NULL)
2240 {
2241 19096 verifyBothWeapons();
2242 19096 load_Sitems(&QMisc);
2243 19096 }
2244 19096 }
2245
2246 // This is used often, so it should be as direct as possible.
2247 2281888513 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2248 {
2249
2/2
✓ Branch 0 taken 2233083987 times.
✓ Branch 1 taken 48804526 times.
2281888513 if(jinx_check)
2250 {
2251
4/4
✓ Branch 0 taken 31164925 times.
✓ Branch 1 taken 17639601 times.
✓ Branch 2 taken 27758483 times.
✓ Branch 3 taken 3406442 times.
48804526 if(!(HeroSwordClk() || HeroItemClk()))
2252 27758483 jinx_check = false; //not jinxed
2253 48804526 }
2254
4/4
✓ Branch 0 taken 2262484973 times.
✓ Branch 1 taken 19403540 times.
✓ Branch 2 taken 20897459 times.
✓ Branch 3 taken 2241587514 times.
2281888513 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2255 {
2256 2241587514 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2257
2258
2/2
✓ Branch 0 taken 2231839002 times.
✓ Branch 1 taken 9748512 times.
2241587514 if(res != itemcache.end())
2259 2231839002 return res->second;
2260 9748512 }
2261
2262 50049511 int32_t result = -1;
2263 50049511 int32_t highestlevel = -1;
2264
2265
2/2
✓ Branch 0 taken 12812674816 times.
✓ Branch 1 taken 50049511 times.
12862724327 for(int32_t i=0; i<MAXITEMS; i++)
2266 {
2267
5/6
✓ Branch 0 taken 1030631229 times.
✓ Branch 1 taken 11782043587 times.
✓ Branch 2 taken 15409904 times.
✓ Branch 3 taken 1015221325 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15409904 times.
12812674816 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2268 {
2269
4/4
✓ Branch 0 taken 4655389 times.
✓ Branch 1 taken 10754515 times.
✓ Branch 2 taken 1195206 times.
✓ Branch 3 taken 14214698 times.
15409904 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2270 {
2271 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2272
2/2
✓ Branch 0 taken 14214578 times.
✓ Branch 1 taken 120 times.
14214698 if(!checkmagiccost(i))
2273 {
2274
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 108 times.
120 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2275 12 }
2276 14214590 }
2277
6/6
✓ Branch 0 taken 13234243 times.
✓ Branch 1 taken 2175553 times.
✓ Branch 2 taken 229100 times.
✓ Branch 3 taken 1946453 times.
✓ Branch 4 taken 1458535 times.
✓ Branch 5 taken 717018 times.
15409796 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2278 {
2279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717018 times.
717018 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2280 717018 continue;
2281 }
2282
2283
2/2
✓ Branch 0 taken 223586 times.
✓ Branch 1 taken 14469192 times.
14692778 if(itemsbuf[i].fam_type >= highestlevel)
2284 {
2285 14469192 highestlevel = itemsbuf[i].fam_type;
2286 14469192 result=i;
2287 14469192 }
2288 14692778 }
2289 12811957690 }
2290
2291
2/2
✓ Branch 0 taken 21046043 times.
✓ Branch 1 taken 29003468 times.
50049511 if(!jinx_check) //Can't cache jinx_check results
2292 29003468 itemcache[itemtype] = result;
2293 50049511 return result;
2294 2281888513 }
2295
2296 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2297 2261123053 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2298 {
2299 2261123053 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2300
2/2
✓ Branch 0 taken 28039066 times.
✓ Branch 1 taken 2233083987 times.
2261123053 if(!jinx_check) //If not already a jinx-immune-only check...
2301 {
2302 //And the player IS jinxed...
2303
4/4
✓ Branch 0 taken 2215675891 times.
✓ Branch 1 taken 17408096 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2212318527 times.
2233083987 if(HeroSwordClk() || HeroItemClk())
2304 {
2305 //Then do a jinx-immune-only check here
2306 20765460 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2307 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2308 //Should NOT need a compat rule, as this should always return -1 in old quests.
2309
2/2
✓ Branch 0 taken 974958 times.
✓ Branch 1 taken 19790502 times.
20765460 if(ret2 > -1) return ret2;
2310 19790502 }
2311 2232109029 }
2312 2260148095 return ret;
2313 2261123053 }
2314 14776608 int32_t current_item_power(int32_t itemtype)
2315 {
2316 14776608 int32_t result = current_item_id(itemtype,true);
2317
2/2
✓ Branch 0 taken 11445380 times.
✓ Branch 1 taken 3331228 times.
14776608 return (result<0) ? 0 : itemsbuf[result].power;
2318 }
2319
2320 7 int32_t heart_container_id()
2321 {
2322
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2323 {
2324
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2325 {
2326 7 return i;
2327 }
2328 196 }
2329 return -1;
2330 7 }
2331
2332 4086346 int32_t item_tile_mod()
2333 {
2334 4086346 int32_t tile=0;
2335
2336
2/2
✓ Branch 0 taken 975760 times.
✓ Branch 1 taken 3110586 times.
4086346 if(game->get_bombs())
2337 {
2338 3110586 int32_t itemid = current_item_id(itype_bomb,false);
2339
3/4
✓ Branch 0 taken 3029527 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3029527 times.
3110586 if(itemid > -1 && checkbunny(itemid))
2340 3029527 tile+=itemsbuf[itemid].ltm;
2341 3110586 }
2342
2343
2/2
✓ Branch 0 taken 3032663 times.
✓ Branch 1 taken 1053683 times.
4086346 if(game->get_sbombs())
2344 {
2345 1053683 int32_t itemid = current_item_id(itype_sbomb,false);
2346
3/4
✓ Branch 0 taken 1052255 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1052255 times.
1053683 if(itemid > -1 && checkbunny(itemid))
2347 1052255 tile+=itemsbuf[itemid].ltm;
2348 1053683 }
2349
2350
2/2
✓ Branch 0 taken 3998396 times.
✓ Branch 1 taken 87950 times.
4086346 if(current_item(itype_clock))
2351 {
2352 87950 int32_t itemid =
2353
1/2
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
87950 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2354 ? iClock
2355 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2356
2/4
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87950 times.
87950 if(itemid > -1 && checkbunny(itemid))
2357 87950 tile+=itemsbuf[itemid].ltm;
2358 87950 }
2359
2360
2/2
✓ Branch 0 taken 3438526 times.
✓ Branch 1 taken 647820 times.
4086346 if(current_item(itype_key))
2361 {
2362 647820 int32_t itemid =
2363
1/2
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
647820 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2364 ? iKey
2365 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2366
2/4
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 647820 times.
647820 if(itemid > -1 && checkbunny(itemid))
2367 647820 tile+=itemsbuf[itemid].ltm;
2368 647820 }
2369
2370
2/2
✓ Branch 0 taken 3927093 times.
✓ Branch 1 taken 159253 times.
4086346 if(current_item(itype_lkey))
2371 {
2372 159253 int32_t itemid =
2373
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2374 ? iLevelKey
2375 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2376
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2377 159253 tile+=itemsbuf[itemid].ltm;
2378 159253 }
2379
2380
2/2
✓ Branch 0 taken 886117 times.
✓ Branch 1 taken 3200229 times.
4086346 if(current_item(itype_map))
2381 {
2382 3200229 int32_t itemid =
2383
2/2
✓ Branch 0 taken 3199443 times.
✓ Branch 1 taken 786 times.
3200229 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2384 ? iMap
2385 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2386
2/4
✓ Branch 0 taken 3200229 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3200229 times.
3200229 if(itemid > -1 && checkbunny(itemid))
2387 3200229 tile+=itemsbuf[itemid].ltm;
2388 3200229 }
2389
2390
2/2
✓ Branch 0 taken 807819 times.
✓ Branch 1 taken 3278527 times.
4086346 if(current_item(itype_compass))
2391 {
2392 3278527 int32_t itemid =
2393
2/2
✓ Branch 0 taken 3197468 times.
✓ Branch 1 taken 81059 times.
3278527 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2394 ? iCompass
2395 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2396
2/4
✓ Branch 0 taken 3278527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3278527 times.
3278527 if(itemid > -1 && checkbunny(itemid))
2397 3278527 tile+=itemsbuf[itemid].ltm;
2398 3278527 }
2399
2400
2/2
✓ Branch 0 taken 2275984 times.
✓ Branch 1 taken 1810362 times.
4086346 if(current_item(itype_bosskey))
2401 {
2402 1810362 int32_t itemid =
2403
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2404 ? iBossKey
2405 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2406
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2407 1810362 tile+=itemsbuf[itemid].ltm;
2408 1810362 }
2409
2410
2/2
✓ Branch 0 taken 2141126 times.
✓ Branch 1 taken 1945220 times.
4086346 if(current_item(itype_magiccontainer))
2411 {
2412 1945220 int32_t itemid =
2413
2/2
✓ Branch 0 taken 1852005 times.
✓ Branch 1 taken 93215 times.
1945220 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2414 ? iMagicC
2415 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2416
3/4
✓ Branch 0 taken 1945220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 1943350 times.
1945220 if(itemid > -1 && checkbunny(itemid))
2417 1943350 tile+=itemsbuf[itemid].ltm;
2418 1945220 }
2419
2420
2/2
✓ Branch 0 taken 1118041 times.
✓ Branch 1 taken 2968305 times.
4086346 if(current_item(itype_triforcepiece))
2421 {
2422 2968305 int32_t itemid =
2423
1/2
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
2968305 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2424 ? iTriforce
2425 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2426
2/4
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2968305 times.
2968305 if(itemid > -1 && checkbunny(itemid))
2427 2968305 tile+=itemsbuf[itemid].ltm;
2428 2968305 }
2429
2430
2/2
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 2092209152 times.
2096295498 for(int32_t i=0; i<itype_max; i++)
2431 {
2432
2/2
✓ Branch 0 taken 2035907072 times.
✓ Branch 1 taken 56302080 times.
2092209152 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2433 {
2434
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2435 {
2436 case itype_bomb:
2437 case itype_sbomb:
2438 case itype_clock:
2439 case itype_key:
2440 case itype_lkey:
2441 case itype_map:
2442 case itype_compass:
2443 case itype_bosskey:
2444 case itype_magiccontainer:
2445 case itype_triforcepiece:
2446 1099650 continue; //already handled
2447 }
2448 55202430 }
2449 2091109502 int32_t itemid = current_item_id(i,false);
2450
2/2
✓ Branch 0 taken 2087023156 times.
✓ Branch 1 taken 4086346 times.
2091109502 if(i == itype_shield)
2451 4086346 itemid = getCurrentShield(false);
2452
2453
4/4
✓ Branch 0 taken 59139201 times.
✓ Branch 1 taken 2031970301 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 59038220 times.
2091109502 if(itemid < 0 || !checkbunny(itemid))
2454 2032071282 continue;
2455
2456 59038220 itemdata const& itm = itemsbuf[itemid];
2457
2458
2/2
✓ Branch 0 taken 55529396 times.
✓ Branch 1 taken 3508824 times.
59038220 switch(itm.family)
2459 {
2460 case itype_shield:
2461
1/2
✓ Branch 0 taken 3508824 times.
✗ Branch 1 not taken.
3508824 if(itm.flags & ITEM_FLAG9) //active shield
2462 {
2463 if(!usingActiveShield(itemid))
2464 {
2465 tile+=itm.misc6; //'Inactive PTM'
2466 continue;
2467 }
2468 }
2469 3508824 break;
2470 }
2471
2472 59038220 tile+=itm.ltm;
2473 59038220 }
2474
2475 4086346 return tile;
2476 }
2477
2478 4086346 int32_t bunny_tile_mod()
2479 {
2480
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4084476 times.
4086346 if(Hero.BunnyClock())
2481 {
2482 1870 return game->get_bunny_ltm();
2483 }
2484 4084476 return 0;
2485 4086346 }
2486
2487 // Hints are drawn on a separate layer to combo reveals.
2488 16332 void draw_lens_under(BITMAP *dest, bool layer)
2489 {
2490 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2491 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2492 //Lens flag 3: Don't show armos/chest/dive items
2493 //Lens flag 4: Show Raft Paths
2494 //Lens flag 5: Show Invisible Enemies
2495
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2496
2497 16332 int32_t strike_hint_table[11]=
2498 {
2499 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2500 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2501 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2502 };
2503
2504 // int32_t page = tmpscr->cpage;
2505 {
2506 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2507 // int32_t temptimer=0;
2508 16332 int32_t tempitem, tempweapon=0;
2509 16332 strike_hint=strike_hint_table[strike_hint_counter];
2510
2511
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2512 {
2513 492 strike_hint_timer=0;
2514 492 strike_hint_counter=((strike_hint_counter+1)%11);
2515 492 }
2516
2517 16332 ++strike_hint_timer;
2518
2519
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2520 {
2521 2874432 int32_t x = (i & 15) << 4;
2522 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2523 2874432 int32_t tempitemx=-16, tempitemy=-16;
2524 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2525
2526
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2527 {
2528 5748864 int32_t checkflag=0;
2529
2530
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2531 {
2532 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2533 2874432 }
2534 else
2535 {
2536 2874432 checkflag=tmpscr->sflag[i];
2537 }
2538
2539
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2540 {
2541
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2542 {
2543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2544 906 }
2545 else
2546 {
2547 192 checkflag = strike_hint;
2548 }
2549 1098 }
2550
2551
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2552 {
2553 case 0:
2554 case mfZELDA:
2555 case mfPUSHED:
2556 case mfENEMY0:
2557 case mfENEMY1:
2558 case mfENEMY2:
2559 case mfENEMY3:
2560 case mfENEMY4:
2561 case mfENEMY5:
2562 case mfENEMY6:
2563 case mfENEMY7:
2564 case mfENEMY8:
2565 case mfENEMY9:
2566 case mfSINGLE:
2567 case mfSINGLE16:
2568 case mfNOENEMY:
2569 case mfTRAP_H:
2570 case mfTRAP_V:
2571 case mfTRAP_4:
2572 case mfTRAP_LR:
2573 case mfTRAP_UD:
2574 case mfNOGROUNDENEMY:
2575 case mfNOBLOCKS:
2576 case mfSCRIPT1:
2577 case mfSCRIPT2:
2578 case mfSCRIPT3:
2579 case mfSCRIPT4:
2580 case mfSCRIPT5:
2581 case mfSCRIPT6:
2582 case mfSCRIPT7:
2583 case mfSCRIPT8:
2584 case mfSCRIPT9:
2585 case mfSCRIPT10:
2586 case mfSCRIPT11:
2587 case mfSCRIPT12:
2588 case mfSCRIPT13:
2589 case mfSCRIPT14:
2590 case mfSCRIPT15:
2591 case mfSCRIPT16:
2592 case mfSCRIPT17:
2593 case mfSCRIPT18:
2594 case mfSCRIPT19:
2595 case mfSCRIPT20:
2596 case mfPITHOLE:
2597 case mfPITFALLFLOOR:
2598 case mfLAVA:
2599 case mfICE:
2600 case mfICEDAMAGE:
2601 case mfDAMAGE1:
2602 case mfDAMAGE2:
2603 case mfDAMAGE4:
2604 case mfDAMAGE8:
2605 case mfDAMAGE16:
2606 case mfDAMAGE32:
2607 case mfFREEZEALL:
2608 case mfFREZEALLANSFFCS:
2609 case mfFREEZEFFCSOLY:
2610 case mfSCRITPTW1TRIG:
2611 case mfSCRITPTW2TRIG:
2612 case mfSCRITPTW3TRIG:
2613 case mfSCRITPTW4TRIG:
2614 case mfSCRITPTW5TRIG:
2615 case mfSCRITPTW6TRIG:
2616 case mfSCRITPTW7TRIG:
2617 case mfSCRITPTW8TRIG:
2618 case mfSCRITPTW9TRIG:
2619 case mfSCRITPTW10TRIG:
2620 case mfTROWEL:
2621 case mfTROWELNEXT:
2622 case mfTROWELSPECIALITEM:
2623 case mfSLASHPOT:
2624 case mfLIFTPOT:
2625 case mfLIFTORSLASH:
2626 case mfLIFTROCK:
2627 case mfLIFTROCKHEAVY:
2628 case mfDROPITEM:
2629 case mfSPECIALITEM:
2630 case mfDROPKEY:
2631 case mfDROPLKEY:
2632 case mfDROPCOMPASS:
2633 case mfDROPMAP:
2634 case mfDROPBOSSKEY:
2635 case mfSPAWNNPC:
2636 case mfSWITCHHOOK:
2637 case mfSIDEVIEWLADDER:
2638 case mfSIDEVIEWPLATFORM:
2639 case mfNOENEMYSPAWN:
2640 case mfENEMYALL:
2641 case mfNOMIRROR:
2642 case mfUNSAFEGROUND:
2643 case mf168:
2644 case mf169:
2645 case mf170:
2646 case mf171:
2647 case mf172:
2648 case mf173:
2649 case mf174:
2650 case mf175:
2651 case mf176:
2652 case mf177:
2653 case mf178:
2654 case mf179:
2655 case mf180:
2656 case mf181:
2657 case mf182:
2658 case mf183:
2659 case mf184:
2660 case mf185:
2661 case mf186:
2662 case mf187:
2663 case mf188:
2664 case mf189:
2665 case mf190:
2666 case mf191:
2667 case mf192:
2668 case mf193:
2669 case mf194:
2670 case mf195:
2671 case mf196:
2672 case mf197:
2673 case mf198:
2674 case mf199:
2675 case mf200:
2676 case mf201:
2677 case mf202:
2678 case mf203:
2679 case mf204:
2680 case mf205:
2681 case mf206:
2682 case mf207:
2683 case mf208:
2684 case mf209:
2685 case mf210:
2686 case mf211:
2687 case mf212:
2688 case mf213:
2689 case mf214:
2690 case mf215:
2691 case mf216:
2692 case mf217:
2693 case mf218:
2694 case mf219:
2695 case mf220:
2696 case mf221:
2697 case mf222:
2698 case mf223:
2699 case mf224:
2700 case mf225:
2701 case mf226:
2702 case mf227:
2703 case mf228:
2704 case mf229:
2705 case mf230:
2706 case mf231:
2707 case mf232:
2708 case mf233:
2709 case mf234:
2710 case mf235:
2711 case mf236:
2712 case mf237:
2713 case mf238:
2714 case mf239:
2715 case mf240:
2716 case mf241:
2717 case mf242:
2718 case mf243:
2719 case mf244:
2720 case mf245:
2721 case mf246:
2722 case mf247:
2723 case mf248:
2724 case mf249:
2725 case mf250:
2726 case mf251:
2727 case mf252:
2728 case mf253:
2729 case mf254:
2730 case mfEXTENDED:
2731 5706470 break;
2732
2733 case mfPUSHUD:
2734 case mfPUSHLR:
2735 case mfPUSH4:
2736 case mfPUSHU:
2737 case mfPUSHD:
2738 case mfPUSHL:
2739 case mfPUSHR:
2740 case mfPUSHUDNS:
2741 case mfPUSHLRNS:
2742 case mfPUSH4NS:
2743 case mfPUSHUNS:
2744 case mfPUSHDNS:
2745 case mfPUSHLNS:
2746 case mfPUSHRNS:
2747 case mfPUSHUDINS:
2748 case mfPUSHLRINS:
2749 case mfPUSH4INS:
2750 case mfPUSHUINS:
2751 case mfPUSHDINS:
2752 case mfPUSHLINS:
2753 case mfPUSHRINS:
2754
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2755
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2756 {
2757 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2758 }
2759
2760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2761
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2762 {
2763
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2764 {
2765
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2766 {
2767 case cPUSH_HEAVY:
2768 case cPUSH_HW:
2769 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2770 72 tempitemx=x, tempitemy=y;
2771
2772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2773 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2774
2775 72 break;
2776
2777 case cPUSH_HEAVY2:
2778 case cPUSH_HW2:
2779 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2780 63 tempitemx=x, tempitemy=y;
2781
2782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2783 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2784
2785 63 break;
2786 }
2787 1032 }
2788 2438 }
2789
2790 3148 break;
2791
2792 case mfWHISTLE:
2793
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2794 {
2795 tempitem=getItemID(itemsbuf,itype_whistle,1);
2796
2797 if(tempitem<0) break;
2798
2799 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2800 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2801 {
2802 tempitemx=x;
2803 tempitemy=y;
2804 }
2805
2806 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2807 }
2808
2809 2418 break;
2810
2811 //Why is this here?
2812 case mfFAIRY:
2813 case mfMAGICFAIRY:
2814 case mfALLFAIRY:
2815 if(hints)
2816 {
2817 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2818
2819 if(tempitem < 0) break;
2820
2821 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2822 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2823 {
2824 tempitemx=x;
2825 tempitemy=y;
2826 }
2827
2828 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2829 }
2830
2831 break;
2832
2833 case mfANYFIRE:
2834
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2835 {
2836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2837 252 }
2838 else
2839 {
2840 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2841
2842
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2843
2844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2845
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2846 {
2847 189 tempitemx=x;
2848 189 tempitemy=y;
2849 189 }
2850
2851 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2852 }
2853
2854 504 break;
2855
2856 case mfSTRONGFIRE:
2857 if(!hints)
2858 {
2859 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2860 }
2861 else
2862 {
2863 tempitem=getItemID(itemsbuf,itype_candle,2);
2864
2865 if(tempitem<0) break;
2866
2867 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2868 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2869 {
2870 tempitemx=x;
2871 tempitemy=y;
2872 }
2873
2874 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2875 }
2876
2877 break;
2878
2879 case mfMAGICFIRE:
2880 if(!hints)
2881 {
2882 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2883 }
2884 else
2885 {
2886 tempitem=getItemID(itemsbuf,itype_wand,1);
2887
2888 if(tempitem<0) break;
2889
2890 tempweapon=wFire;
2891
2892 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2893 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2894 {
2895 tempitemx=x;
2896 tempitemy=y;
2897 }
2898 else
2899 {
2900 tempweaponx=x;
2901 tempweapony=y;
2902 }
2903
2904 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2905 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2906 }
2907
2908 break;
2909
2910 case mfDIVINEFIRE:
2911 if(!hints)
2912 {
2913 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2914 }
2915 else
2916 {
2917 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2918
2919 if(tempitem<0) break;
2920
2921 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2922 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2923 {
2924 tempitemx=x;
2925 tempitemy=y;
2926 }
2927
2928 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2929 }
2930
2931 break;
2932
2933 case mfARROW:
2934
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2935 {
2936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2937 732 }
2938 else
2939 {
2940 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2941
2942
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2943
2944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2945
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2946 {
2947 61 tempitemx=x;
2948 61 tempitemy=y;
2949 61 }
2950
2951 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2952 }
2953
2954 814 break;
2955
2956 case mfSARROW:
2957 if(!hints)
2958 {
2959 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2960 }
2961 else
2962 {
2963 tempitem=getItemID(itemsbuf,itype_arrow,2);
2964
2965 if(tempitem<0) break;
2966
2967 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2968 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2969 {
2970 tempitemx=x;
2971 tempitemy=y;
2972 }
2973
2974 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2975 }
2976
2977 break;
2978
2979 case mfGARROW:
2980 if(!hints)
2981 {
2982 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2983 }
2984 else
2985 {
2986 tempitem=getItemID(itemsbuf,itype_arrow,3);
2987
2988 if(tempitem<0) break;
2989
2990 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2991 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2992 {
2993 tempitemx=x;
2994 tempitemy=y;
2995 }
2996
2997 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2998 }
2999
3000 break;
3001
3002 case mfBOMB:
3003
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3004 {
3005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3006 16 }
3007 else
3008 {
3009 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3010 17 tempweapon = wLitBomb;
3011
3012 //if (tempitem<0) break;
3013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3014
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3015 {
3016 12 tempweaponx=x;
3017 12 tempweapony=y;
3018 12 }
3019
3020 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3021 }
3022
3023 33 break;
3024
3025 case mfSBOMB:
3026
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3027 {
3028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3029 48 }
3030 else
3031 {
3032 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3033 //if (tempitem<0) break;
3034 48 tempweapon = wLitSBomb;
3035
3036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3037
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3038 {
3039 36 tempweaponx=x;
3040 36 tempweapony=y;
3041 36 }
3042
3043 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3044 }
3045
3046 96 break;
3047
3048 case mfARMOS_SECRET:
3049
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3050 {
3051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3052 12 }
3053 24 break;
3054
3055 case mfBRANG:
3056
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3057 {
3058 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3059 }
3060 else
3061 {
3062 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3063
3064
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3065
3066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3067
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3068 {
3069 4 tempitemx=x;
3070 4 tempitemy=y;
3071 4 }
3072
3073 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3074 }
3075
3076 5 break;
3077
3078 case mfMBRANG:
3079 if(!hints)
3080 {
3081 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3082 }
3083 else
3084 {
3085 tempitem=getItemID(itemsbuf,itype_brang,2);
3086
3087 if(tempitem<0) break;
3088
3089 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3090 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3091 {
3092 tempitemx=x;
3093 tempitemy=y;
3094 }
3095
3096 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3097 }
3098
3099 break;
3100
3101 case mfFBRANG:
3102 if(!hints)
3103 {
3104 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3105 }
3106 else
3107 {
3108 tempitem=getItemID(itemsbuf,itype_brang,3);
3109
3110 if(tempitem<0) break;
3111
3112 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3113 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3114 {
3115 tempitemx=x;
3116 tempitemy=y;
3117 }
3118
3119 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3120 }
3121
3122 break;
3123
3124 case mfWANDMAGIC:
3125 if(!hints)
3126 {
3127 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3128 }
3129 else
3130 {
3131 tempitem=getItemID(itemsbuf,itype_wand,1);
3132
3133 if(tempitem<0) break;
3134
3135 tempweapon=itemsbuf[tempitem].wpn3;
3136
3137 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3138 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3139 {
3140 tempitemx=x;
3141 tempitemy=y;
3142 }
3143 else
3144 {
3145 tempweaponx=x;
3146 tempweapony=y;
3147 --lens_hint_weapon[wMagic][4];
3148
3149 if(lens_hint_weapon[wMagic][4]<-8)
3150 {
3151 lens_hint_weapon[wMagic][4]=8;
3152 }
3153 }
3154
3155 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3156 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3157 }
3158
3159 break;
3160
3161 case mfREFMAGIC:
3162
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3163 {
3164 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3165 }
3166 else
3167 {
3168 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3169
3170
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3171
3172 16 tempweapon=ewMagic;
3173
3174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3175
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3176 {
3177 13 tempitemx=x;
3178 13 tempitemy=y;
3179 13 }
3180 else
3181 {
3182 3 tempweaponx=x;
3183 3 tempweapony=y;
3184
3185
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3186 {
3187 1 --lens_hint_weapon[ewMagic][4];
3188 1 }
3189 else
3190 {
3191 2 ++lens_hint_weapon[ewMagic][4];
3192 }
3193
3194
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3195 {
3196 lens_hint_weapon[ewMagic][2]=up;
3197 }
3198
3199
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3200 {
3201 2 lens_hint_weapon[ewMagic][2]=down;
3202 2 }
3203 }
3204
3205 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3206 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3207 }
3208
3209 16 break;
3210
3211 case mfREFFIREBALL:
3212
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3213 {
3214 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3215 }
3216 else
3217 {
3218 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3219
3220
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3221
3222 16 tempweapon=ewFireball;
3223
3224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3225
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3226 {
3227 12 tempitemx=x;
3228 12 tempitemy=y;
3229 12 tempweaponx=x;
3230 12 tempweapony=y;
3231 12 ++lens_hint_weapon[ewFireball][3];
3232
3233
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3234 {
3235 1 lens_hint_weapon[ewFireball][3]=-8;
3236 1 lens_hint_weapon[ewFireball][4]=8;
3237 1 }
3238
3239
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3240 {
3241 8 ++lens_hint_weapon[ewFireball][4];
3242 8 }
3243 else
3244 {
3245 4 --lens_hint_weapon[ewFireball][4];
3246 }
3247 12 }
3248
3249 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3250 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3251 }
3252
3253 16 break;
3254
3255 case mfSWORD:
3256
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3257 {
3258 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3259 }
3260 else
3261 {
3262 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3263
3264
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3265
3266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3267
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3268 {
3269 5 tempitemx=x;
3270 5 tempitemy=y;
3271 5 }
3272
3273 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3274 }
3275
3276 7 break;
3277
3278 case mfWSWORD:
3279 if(!hints)
3280 {
3281 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3282 }
3283 else
3284 {
3285 tempitem=getItemID(itemsbuf,itype_sword,2);
3286
3287 if(tempitem<0) break;
3288
3289 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3290 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3291 {
3292 tempitemx=x;
3293 tempitemy=y;
3294 }
3295
3296 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3297 }
3298
3299 break;
3300
3301 case mfMSWORD:
3302 if(!hints)
3303 {
3304 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3305 }
3306 else
3307 {
3308 tempitem=getItemID(itemsbuf,itype_sword,3);
3309
3310 if(tempitem<0) break;
3311
3312 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3313 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3314 {
3315 tempitemx=x;
3316 tempitemy=y;
3317 }
3318
3319 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3320 }
3321
3322 break;
3323
3324 case mfXSWORD:
3325 if(!hints)
3326 {
3327 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3328 }
3329 else
3330 {
3331 tempitem=getItemID(itemsbuf,itype_sword,4);
3332
3333 if(tempitem<0) break;
3334
3335 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3336 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3337 {
3338 tempitemx=x;
3339 tempitemy=y;
3340 }
3341
3342 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3343 }
3344
3345 break;
3346
3347 case mfSWORDBEAM:
3348
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3349 {
3350 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3351 }
3352 else
3353 {
3354 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3355
3356
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3357
3358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3359
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3360 {
3361 11 tempitemx=x;
3362 11 tempitemy=y;
3363 11 }
3364
3365 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3366 }
3367
3368 16 break;
3369
3370 case mfWSWORDBEAM:
3371 if(!hints)
3372 {
3373 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3374 }
3375 else
3376 {
3377 tempitem=getItemID(itemsbuf,itype_sword,2);
3378
3379 if(tempitem<0) break;
3380
3381 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3382 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3383 {
3384 tempitemx=x;
3385 tempitemy=y;
3386 }
3387
3388 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3389 }
3390
3391 break;
3392
3393 case mfMSWORDBEAM:
3394 if(!hints)
3395 {
3396 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3397 }
3398 else
3399 {
3400 tempitem=getItemID(itemsbuf,itype_sword,3);
3401
3402 if(tempitem<0) break;
3403
3404 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3405 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3406 {
3407 tempitemx=x;
3408 tempitemy=y;
3409 }
3410
3411 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3412 }
3413
3414 break;
3415
3416 case mfXSWORDBEAM:
3417 if(!hints)
3418 {
3419 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3420 }
3421 else
3422 {
3423 tempitem=getItemID(itemsbuf,itype_sword,4);
3424
3425 if(tempitem<0) break;
3426
3427 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3428 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3429 {
3430 tempitemx=x;
3431 tempitemy=y;
3432 }
3433
3434 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3435 }
3436
3437 break;
3438
3439 case mfHOOKSHOT:
3440
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3441 {
3442 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3443 }
3444 else
3445 {
3446 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3447
3448
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3449
3450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3451
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3452 {
3453 12 tempitemx=x;
3454 12 tempitemy=y;
3455 12 }
3456
3457 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3458 }
3459
3460 17 break;
3461
3462 case mfWAND:
3463
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3464 {
3465 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3466 }
3467 else
3468 {
3469 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3470
3471
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3472
3473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3474
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3475 {
3476 28 tempitemx=x;
3477 28 tempitemy=y;
3478 28 }
3479
3480 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3481 }
3482
3483 35 break;
3484
3485 case mfHAMMER:
3486
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3487 {
3488 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3489 }
3490 else
3491 {
3492 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3493
3494
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3495
3496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3497
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3498 {
3499 13 tempitemx=x;
3500 13 tempitemy=y;
3501 13 }
3502
3503 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3504 }
3505
3506 17 break;
3507
3508 case mfARMOS_ITEM:
3509 case mfDIVE_ITEM:
3510
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3511 {
3512 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3513 2064 }
3514 2064 break;
3515
3516 case 16:
3517 case 17:
3518 case 18:
3519 case 19:
3520 case 20:
3521 case 21:
3522 case 22:
3523 case 23:
3524 case 24:
3525 case 25:
3526 case 26:
3527 case 27:
3528 case 28:
3529 case 29:
3530 case 30:
3531 case 31:
3532
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3534 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3535
3536 3618 break;
3537 case mfSECRETSNEXT:
3538 if(!hints)
3539 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3540 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3541
3542 break;
3543
3544 case mfSTRIKE:
3545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3546 {
3547 906 goto special;
3548 }
3549 else
3550 {
3551 break;
3552 }
3553
3554 28640 default: goto special;
3555
3556 special:
3557
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3558 {
3559
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3560 {
3561 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3562 4913 }
3563 6549 }
3564
3565 29546 break;
3566 }
3567 5748864 }
3568 2874432 }
3569
3570
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3571 {
3572
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3573 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3574
3575
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3576 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3577
3578
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3579 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3580
3581
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3582 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3583
3584
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3585 {
3586 43 showbombeddoor(dest, 0);
3587 43 }
3588
3589
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3590 {
3591 39 showbombeddoor(dest, 1);
3592 39 }
3593
3594
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3595 {
3596 showbombeddoor(dest, 2);
3597 }
3598
3599
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3600 {
3601 37 showbombeddoor(dest, 3);
3602 37 }
3603 8166 }
3604
3605
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3606 {
3607
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3608 {
3609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3610 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3611 1123 }
3612 else
3613 {
3614
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3615 {
3616 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3617 48 int32_t tempitemx=-16;
3618 48 int32_t tempitemy=-16;
3619
3620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3621
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3622 {
3623 24 tempitemx=tmpscr->stairx;
3624 24 tempitemy=tmpscr->stairy+playing_field_offset;
3625 24 }
3626
3627 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3628 48 }
3629 }
3630 2034 }
3631 }
3632 16332 }
3633
3634 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3635
3636 7997 void draw_lens_over()
3637 {
3638 // Oh, what the heck.
3639 static BITMAP *lens_scr = NULL;
3640 static int32_t last_width = -1;
3641 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3642
3643 // Only redraw the circle if the size has changed
3644
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3645 {
3646
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3647 {
3648 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3649 5 }
3650
3651 5 clear_to_color(lens_scr, BLACK);
3652 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3653 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3654 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3655 5 last_width=width;
3656 5 }
3657
3658 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3659 7997 }
3660
3661 //----------------------------------------------------------------
3662
3663 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3664 {
3665 //recreating a big bitmap every frame is highly sluggish.
3666
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3667 30701 clear_to_color(wavebuf, BLACK);
3668 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3669
3670 int32_t ofs;
3671 // int32_t amplitude=8;
3672 // int32_t wavelength=4;
3673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3674
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3675 30701 int32_t amp2=168;
3676
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3677 30701 int32_t i=frame%amp2;
3678
3679
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3680 {
3681
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3682 {
3683 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3684 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3685 }
3686 else
3687 {
3688 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3689 }
3690
3691
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3692 {
3693
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3694 {
3695 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3696 1320388608 }
3697 5157768 }
3698 5157768 }
3699 30701 }
3700
3701 2832 void draw_fuzzy(int32_t fuzz)
3702 // draws from right half of scrollbuf to framebuf
3703 {
3704 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3705 byte *start, *si, *di;
3706
3707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2832 times.
2832 if(fuzz<1)
3708 fuzz = 1;
3709
3710 2832 xstep = 128%fuzz;
3711
3712
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2242 times.
2832 if(xstep > 0)
3713 2242 xstep = fuzz-xstep;
3714
3715 2832 ystep = 112%fuzz;
3716
3717
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 2006 times.
2832 if(ystep > 0)
3718 2006 ystep = fuzz-ystep;
3719
3720 2832 firsty = 1;
3721
3722
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 102188 times.
105020 for(y=0; y<224;)
3723 {
3724 102188 start = &(scrollbuf->line[y][256]);
3725
3726
4/4
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 635784 times.
✓ Branch 2 taken 634368 times.
✓ Branch 3 taken 102188 times.
736556 for(dy=0; dy<ystep && dy+y<224; dy++)
3727 {
3728 634368 si = start;
3729 634368 di = &(framebuf->line[y+dy][0]);
3730 634368 i = xstep;
3731 634368 firstx = 1;
3732
3733
2/2
✓ Branch 0 taken 162398208 times.
✓ Branch 1 taken 634368 times.
163032576 for(dx=0; dx<256; dx++)
3734 {
3735 162398208 *(di++) = *si;
3736
3737
2/2
✓ Branch 0 taken 136838464 times.
✓ Branch 1 taken 25559744 times.
162398208 if(++i >= fuzz)
3738 {
3739
2/2
✓ Branch 0 taken 24925376 times.
✓ Branch 1 taken 634368 times.
25559744 if(!firstx)
3740 24925376 si += fuzz;
3741 else
3742 {
3743 634368 si += fuzz-xstep;
3744 634368 firstx = 0;
3745 }
3746
3747 25559744 i = 0;
3748 25559744 }
3749 162398208 }
3750 634368 }
3751
3752
2/2
✓ Branch 0 taken 99356 times.
✓ Branch 1 taken 2832 times.
102188 if(!firsty)
3753 99356 y += fuzz;
3754 else
3755 {
3756 2832 y += ystep;
3757 2832 ystep = fuzz;
3758 2832 firsty = 0;
3759 }
3760 }
3761 2832 }
3762
3763 6510665 void updatescr(bool allowwavy)
3764 {
3765
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
6510665 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3766
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
6510665 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3767
3768
2/2
✓ Branch 0 taken 6484961 times.
✓ Branch 1 taken 25704 times.
6510665 if(toogam)
3769 {
3770 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3771 25704 }
3772
3773
1/2
✓ Branch 0 taken 6510665 times.
✗ Branch 1 not taken.
6510665 if(Showpal)
3774 dump_pal(framebuf);
3775
3776
2/2
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
6510665 if(!Playing)
3777 82022 black_opening_count=0;
3778
3779
2/2
✓ Branch 0 taken 6472715 times.
✓ Branch 1 taken 37950 times.
6510665 if(black_opening_count<0) //shape is opening up
3780 {
3781 37950 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3782
3783
2/4
✓ Branch 0 taken 37950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37950 times.
37950 if(Advance||(!Paused))
3784 {
3785 37950 ++black_opening_count;
3786 37950 }
3787 37950 }
3788
2/2
✓ Branch 0 taken 6458459 times.
✓ Branch 1 taken 14256 times.
6472715 else if(black_opening_count>0) //shape is closing
3789 {
3790 14256 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3791
3792
2/4
✓ Branch 0 taken 14256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14256 times.
14256 if(Advance||(!Paused))
3793 {
3794 14256 --black_opening_count;
3795 14256 }
3796 14256 }
3797
3798
3/4
✓ Branch 0 taken 6459250 times.
✓ Branch 1 taken 51415 times.
✓ Branch 2 taken 6459250 times.
✗ Branch 3 not taken.
6510665 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3799 {
3800 black_opening_shape = bosCIRCLE;
3801 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3802 refreshTints();
3803 refreshpal=true;
3804 }
3805
3806
2/2
✓ Branch 0 taken 6298112 times.
✓ Branch 1 taken 212553 times.
6510665 if(refreshpal)
3807 {
3808 212553 refreshpal=false;
3809 212553 RAMpal[253] = _RGB(0,0,0);
3810 212553 RAMpal[254] = _RGB(63,63,63);
3811 212553 hw_palette = &RAMpal;
3812 212553 update_hw_pal = true;
3813
3814 212553 create_rgb_table(&rgb_table, RAMpal, NULL);
3815 212553 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3816 212553 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3817
3818
2/2
✓ Branch 0 taken 54413568 times.
✓ Branch 1 taken 212553 times.
54626121 for(int32_t q=0; q<PAL_SIZE; q++)
3819 {
3820 54413568 trans_table2.data[0][q] = q;
3821 54413568 trans_table2.data[q][q] = q;
3822 54413568 }
3823 212553 }
3824
3825 6510665 bool clearwavy = (wavy <= 0);
3826
3827
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 6503420 times.
6510665 if(wavy <= 0)
3828 {
3829 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3830 6503420 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3831 6503420 }
3832
3833 6510665 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3834
3835
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 6479714 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
6510665 if(wavy && Playing && allowwavy)
3836 {
3837 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3838 30701 }
3839
3840
2/2
✓ Branch 0 taken 6503420 times.
✓ Branch 1 taken 7245 times.
6510665 if(clearwavy)
3841 6503420 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3842
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3843 7245 wavy--; // Wavy was set by a script. Decrement it.
3844
3845
5/6
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
✓ Branch 2 taken 125857 times.
✓ Branch 3 taken 6302786 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125857 times.
6510665 if(Playing && msgpos && !screenscrolling)
3846 {
3847
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_bg_display_buf->clip))
3848 125857 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3849
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_portrait_display_buf->clip))
3850 125857 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3851
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_txt_display_buf->clip))
3852 125857 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3853 125857 }
3854
3855 /*
3856 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3857 {
3858 BITMAP* subBmp = 0;
3859 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3860 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3861 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3862 destroy_bitmap(subBmp);
3863 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3864 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3865 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3866 }
3867 */
3868
3869
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3870
3871
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 if(nosubscr)
3872 {
3873 25179 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3874 25179 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3875 25179 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3876 25179 }
3877
3878 //TODO: Optimize blit 'overcalls' -Gleeok
3879
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 6485486 times.
6510665 BITMAP *source = nosubscr ? panorama : wavybuf;
3880 6510665 blit(source,framebuf,0,0,0,0,256,224);
3881
3882 6510665 update_hw_screen();
3883 6510665 }
3884
3885 //----------------------------------------------------------------
3886
3887 PALETTE sys_pal;
3888
3889 int32_t onGUISnapshot()
3890 {
3891 char buf[200];
3892 int32_t num=0;
3893 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3894 do
3895 {
3896 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3897 }
3898 while(num<99999 && exists(buf));
3899
3900 BITMAP *b = create_bitmap_ex(8,resx,resy);
3901
3902 if(b)
3903 {
3904 if(MenuOpen)
3905 {
3906 //Cannot load game's palette while GUI elements are in focus. -Z
3907 //If there is a way to do this, then I have missed it.
3908 /*
3909 game_pal();
3910 RAMpal[253] = _RGB(0,0,0);
3911 RAMpal[254] = _RGB(63,63,63);
3912 set_palette_range(RAMpal,0,255,false);
3913 memcpy(RAMpal, snappal, sizeof(snappal));
3914 create_rgb_table(&rgb_table, RAMpal, NULL);
3915 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3916 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3917
3918 for(int32_t q=0; q<PAL_SIZE; q++)
3919 {
3920 trans_table2.data[0][q] = q;
3921 trans_table2.data[q][q] = q;
3922 }
3923 */
3924 //ringcolor(false);
3925 //get_palette(RAMpal);
3926 blit(screen,b,0,0,0,0,resx,resy);
3927 //al_trace("Menu Open\n");
3928 //game_pal();
3929 //PALETTE temppal;
3930 //get_palette(temppal);
3931 //system_pal();
3932 save_bitmap(buf,b,sys_pal);
3933 //save_bitmap(buf,b,RAMpal);
3934 //save_bitmap(buf,b,snappal);
3935 }
3936 else
3937 {
3938 blit(screen,b,0,0,0,0,resx,resy);
3939 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3940 }
3941 destroy_bitmap(b);
3942 }
3943
3944 return D_O_K;
3945 }
3946
3947 int32_t onNonGUISnapshot()
3948 {
3949 PALETTE temppal;
3950 get_palette(temppal);
3951 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3952
3953 char buf[200];
3954 int32_t num=0;
3955
3956 do
3957 {
3958 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3959 }
3960 while(num<99999 && exists(buf));
3961
3962 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3963
3964 return D_O_K;
3965 }
3966
3967 int32_t onSnapshot()
3968 {
3969 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3970 {
3971 onGUISnapshot();
3972 }
3973 else
3974 {
3975 onNonGUISnapshot();
3976 }
3977
3978 return D_O_K;
3979 }
3980
3981 int32_t onSaveMapPic()
3982 {
3983 int32_t mapres2 = 0;
3984 char buf[200];
3985 int32_t num=0;
3986 mapscr tmpscr_b[2];
3987 mapscr tmpscr_c[6];
3988 BITMAP* _screen_draw_buffer = NULL;
3989 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3990 set_clip_state(_screen_draw_buffer,1);
3991
3992 for(int32_t i=0; i<6; ++i)
3993 {
3994 tmpscr_c[i] = tmpscr2[i];
3995 tmpscr2[i].zero_memory();
3996
3997 if(i>=2)
3998 {
3999 continue;
4000 }
4001
4002 tmpscr_b[i] = tmpscr[i];
4003 tmpscr[i].zero_memory();
4004 }
4005
4006 do
4007 {
4008 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4009 }
4010 while(num<99999 && exists(buf));
4011
4012 BITMAP* mappic = NULL;
4013
4014
4015 bool done=false, redraw=true;
4016
4017 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4018
4019 if(!mappic)
4020 {
4021 system_pal();
4022 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4023 game_pal();
4024 return D_O_K;;
4025 }
4026
4027 // draw the map
4028 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4029
4030 for(int32_t y=0; y<8; y++)
4031 {
4032 for(int32_t x=0; x<16; x++)
4033 {
4034 if(!displayOnMap(x, y))
4035 {
4036 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4037 }
4038 else
4039 {
4040 int32_t s = (y<<4) + x;
4041 loadscr2(1,s,-1);
4042
4043 for(int32_t i=0; i<6; i++)
4044 {
4045 if(tmpscr[1].layermap[i]<=0)
4046 continue;
4047
4048 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4049 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4050 {
4051 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4052
4053 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4054 }
4055 }
4056
4057 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4058
4059 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4060
4061 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4062 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4063
4064 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4065
4066 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4067 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4068 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4069 {
4070 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4071 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4072 }
4073 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4074
4075 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4076
4077 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4078 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4079 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4080 {
4081 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4082 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4083 }
4084 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4085 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4086
4087 }
4088
4089 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4090 }
4091 }
4092
4093 for(int32_t i=0; i<6; ++i)
4094 {
4095 tmpscr2[i]=tmpscr_c[i];
4096
4097 if(i>=2)
4098 {
4099 continue;
4100 }
4101
4102 tmpscr[i]=tmpscr_b[i];
4103 }
4104
4105 save_bitmap(buf,mappic,RAMpal);
4106 destroy_bitmap(mappic);
4107 destroy_bitmap(_screen_draw_buffer);
4108 return D_O_K;
4109 }
4110
4111 /*
4112 int32_t onSaveMapPic()
4113 {
4114 BITMAP* mappic = NULL;
4115 BITMAP* _screen_draw_buffer = NULL;
4116 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4117 int32_t mapres2 = 0;
4118 char buf[20];
4119 int32_t num=0;
4120 set_clip_state(_screen_draw_buffer,1);
4121 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4122
4123 do
4124 {
4125 sprintf(buf, "zelda%03d.png", ++num);
4126 }
4127 while(num<999 && exists(buf));
4128
4129 // if(!mappic) {
4130 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4131
4132 if(!mappic)
4133 {
4134 system_pal();
4135 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4136 game_pal();
4137 return D_O_K;
4138 }
4139
4140 // }
4141
4142 int32_t layermap, layerscreen;
4143 int32_t x2=0;
4144
4145 // draw the map
4146 for(int32_t y=0; y<8; y++)
4147 {
4148 for(int32_t x=0; x<16; x++)
4149 {
4150 int32_t s = (y<<4) + x;
4151
4152 if(!displayOnMap(x, y))
4153 {
4154 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4155 }
4156 else
4157 {
4158 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4159 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4160
4161 for(int32_t k=0; k<4; k++)
4162 {
4163 if(k==2)
4164 {
4165 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4166 }
4167
4168 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4169
4170 if(layermap>-1)
4171 {
4172 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4173
4174 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4175 {
4176 for(int32_t i=0; i<176; i++)
4177 {
4178 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4179 }
4180 }
4181 else
4182 {
4183 for(int32_t i=0; i<176; i++)
4184 {
4185 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4186 }
4187 }
4188 }
4189 }
4190
4191 for(int32_t i=0; i<176; i++)
4192 {
4193 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4194 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4195 {
4196 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4197 }
4198 }
4199
4200 for(int32_t k=4; k<6; k++)
4201 {
4202 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4203
4204 if(layermap>-1)
4205 {
4206 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4207
4208 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4209 {
4210 for(int32_t i=0; i<176; i++)
4211 {
4212 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4213 }
4214 }
4215 else
4216 {
4217 for(int32_t i=0; i<176; i++)
4218 {
4219 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4220 }
4221 }
4222 }
4223 }
4224 }
4225
4226 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4227 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4228 }
4229
4230 }
4231
4232 save_bitmap(buf,mappic,RAMpal);
4233 destroy_bitmap(mappic);
4234 destroy_bitmap(_screen_draw_buffer);
4235 return D_O_K;
4236 }
4237 */
4238
4239 14 void f_Quit(int32_t type)
4240 {
4241
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4242 return;
4243
4244 14 bool from_menu = is_sys_pal;
4245
4246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4247 {
4248 14 music_pause();
4249 14 pause_all_sfx();
4250 14 }
4251 14 enter_sys_pal();
4252 14 clear_keybuf();
4253
4254
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4255 14 replay_poll();
4256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4257 14 replay_peek_quit();
4258
4259
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4260 switch(type)
4261 {
4262 case qQUIT:
4263 onQuit();
4264 break;
4265
4266 case qRESET:
4267 onReset();
4268 break;
4269
4270 case qEXIT:
4271 onExit();
4272 break;
4273 }
4274
4275
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4276 {
4277 14 kill_sfx();
4278 14 music_stop();
4279 14 exit_sys_pal();
4280 14 update_hw_screen();
4281 14 }
4282 else
4283 {
4284 exit_sys_pal();
4285 if(!from_menu)
4286 {
4287 music_resume();
4288 resume_all_sfx();
4289 }
4290 }
4291
4292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4293 14 show_mouse(NULL);
4294 14 eat_buttons();
4295
4296 14 zc_readrawkey(KEY_ESC);
4297
4298 14 zc_readrawkey(KEY_ENTER);
4299 14 }
4300
4301 //----------------------------------------------------------------
4302
4303 int32_t onNoWalls()
4304 {
4305 cheats_enqueue(Cheat::Walls);
4306 return D_O_K;
4307 }
4308
4309 int32_t onIgnoreSideview()
4310 {
4311 cheats_enqueue(Cheat::IgnoreSideView);
4312 return D_O_K;
4313 }
4314
4315 6510614 int32_t input_idle(bool checkmouse)
4316 {
4317 static int32_t mx, my, mz, mb;
4318
4319
4/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✓ Branch 3 taken 4889582 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1621032 times.
8131646 if(keypressed() || zc_key_pressed() ||
4320
4/8
✓ Branch 0 taken 1621032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1621032 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1621032 times.
✗ Branch 7 not taken.
1621032 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4321 {
4322 4889582 idle_count = 0;
4323
4324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4889582 times.
4889582 if(active_count < MAX_ACTIVE)
4325 {
4326 4889582 ++active_count;
4327 4889582 }
4328 4889582 }
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1621032 times.
1621032 else if(idle_count < MAX_IDLE)
4330 {
4331 1621032 ++idle_count;
4332 1621032 active_count = 0;
4333 1621032 }
4334
4335 6510614 mx = mouse_x;
4336 6510614 my = mouse_y;
4337 6510614 mz = mouse_z;
4338 6510614 mb = mouse_b;
4339
4340 6510614 return idle_count;
4341 }
4342
4343 int32_t onGoFast()
4344 {
4345 cheats_enqueue(Cheat::Fast);
4346 return D_O_K;
4347 }
4348
4349 int32_t onKillCheat()
4350 {
4351 cheats_enqueue(Cheat::Kill);
4352 return D_O_K;
4353 }
4354
4355 int32_t onSecretsCheat()
4356 {
4357 cheats_enqueue(Cheat::TrigSecrets);
4358 return D_O_K;
4359 }
4360 int32_t onSecretsCheatPerm()
4361 {
4362 cheats_enqueue(Cheat::TrigSecretsPerm);
4363 return D_O_K;
4364 }
4365
4366 int32_t onShowLayer0()
4367 {
4368 show_layer_0 = !show_layer_0;
4369 return D_O_K;
4370 }
4371 int32_t onShowLayer1()
4372 {
4373 show_layer_1 = !show_layer_1;
4374 return D_O_K;
4375 }
4376 int32_t onShowLayer2()
4377 {
4378 show_layer_2 = !show_layer_2;
4379 return D_O_K;
4380 }
4381 int32_t onShowLayer3()
4382 {
4383 show_layer_3 = !show_layer_3;
4384 return D_O_K;
4385 }
4386 int32_t onShowLayer4()
4387 {
4388 show_layer_4 = !show_layer_4;
4389 return D_O_K;
4390 }
4391 int32_t onShowLayer5()
4392 {
4393 show_layer_5 = !show_layer_5;
4394 return D_O_K;
4395 }
4396 int32_t onShowLayer6()
4397 {
4398 show_layer_6 = !show_layer_6;
4399 return D_O_K;
4400 }
4401 int32_t onShowLayerO()
4402 {
4403 show_layer_over=!show_layer_over;
4404 return D_O_K;
4405 }
4406 int32_t onShowLayerP()
4407 {
4408 show_layer_push=!show_layer_push;
4409 return D_O_K;
4410 }
4411 int32_t onShowLayerS()
4412 {
4413 show_sprites=!show_sprites;
4414 return D_O_K;
4415 }
4416 int32_t onShowLayerF()
4417 {
4418 show_ffcs=!show_ffcs;
4419 return D_O_K;
4420 }
4421 int32_t onShowLayerW()
4422 {
4423 show_walkflags=!show_walkflags;
4424 if(show_walkflags)
4425 show_effectflags = false;
4426 return D_O_K;
4427 }
4428 int32_t onShowLayerE()
4429 {
4430 show_effectflags=!show_effectflags;
4431 if(show_effectflags)
4432 show_walkflags = false;
4433 return D_O_K;
4434 }
4435 int32_t onShowFFScripts()
4436 {
4437 show_ff_scripts=!show_ff_scripts;
4438 return D_O_K;
4439 }
4440 int32_t onShowHitboxes()
4441 {
4442 show_hitboxes=!show_hitboxes;
4443 return D_O_K;
4444 }
4445 int32_t onShowInfoOpacity()
4446 {
4447 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4448 zc_set_config("zc","debug_info_opacity",info_opacity);
4449 return D_O_K;
4450 }
4451
4452 int32_t onLightSwitch()
4453 {
4454 cheats_enqueue(Cheat::Light);
4455 return D_O_K;
4456 }
4457
4458 int32_t onGoTo();
4459 int32_t onGoToComplete();
4460
4461 6510614 void syskeys()
4462 {
4463 6510614 update_system_keys();
4464
4465 int32_t oldtitle_version;
4466
4467
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(close_button_quit)
4468 {
4469 close_button_quit=false;
4470 f_Quit(qEXIT);
4471 }
4472
4473 6510614 poll_joystick();
4474
4475
2/10
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510614 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6510614 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4476 {
4477 oldtitle_version=title_version;
4478 System();
4479 }
4480
4481 6510614 mouse_down=gui_mouse_b();
4482
4483
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F1))
4484 {
4485 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4486 {
4487 halt=!halt;
4488 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4489 }
4490 else
4491 {
4492 Throttlefps=!Throttlefps;
4493 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4494 logic_counter=0;
4495 }
4496 }
4497
4498 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4499 /*
4500 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4501 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4502 */
4503
4504
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F2))
4505 {
4506 ShowFPS=!ShowFPS;
4507 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4508 }
4509
4510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4511
4512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F4) && Playing)
4513 {
4514 Paused=true;
4515 Advance=true;
4516 }
4517
4518
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F6)) onTryQuit();
4519
4520 #ifndef ALLEGRO_MACOSX
4521
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4522
4523
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4524 #else
4525 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4526
4527 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4528 #endif
4529
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6510614 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4530
4531
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (zc_read_system_key(KEY_F12))
4532 {
4533 onSnapshot();
4534 }
4535
4536
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(debug_enabled && zc_read_system_key(KEY_TAB))
4537 set_debug(!get_debug());
4538
4539
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(CheatModifierKeys())
4540 {
4541 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4542 {
4543 if(!bindable_cheat(c))
4544 continue;
4545 if(get_debug() || cheat >= cheat_lvl(c))
4546 {
4547 if(checkcheat(c))
4548 cheats_hit_bind(c);
4549 }
4550 }
4551 }
4552
4553
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(volkeys)
4554 {
4555 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4556
4557 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4558
4559 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4560
4561 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4562 }
4563
4564
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6510614 if(!get_debug() || !SystemKeys || replay_is_replaying())
4565 6510614 goto bottom;
4566
4567 if(zc_readkey(KEY_D))
4568 {
4569 details = !details;
4570 rectfill(screen,0,0,319,7,BLACK);
4571 rectfill(screen,0,8,31,239,BLACK);
4572 rectfill(screen,288,8,319,239,BLACK);
4573 rectfill(screen,32,232,287,239,BLACK);
4574 }
4575
4576 if(zc_readkey(KEY_P)) Paused=!Paused;
4577
4578 //if(zc_readkey(KEY_P)) centerHero();
4579 if(zc_readkey(KEY_A))
4580 {
4581 Paused=true;
4582 Advance=true;
4583 }
4584
4585 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4586 #ifndef ALLEGRO_MACOSX
4587 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4588
4589 if(zc_readkey(KEY_F7))
4590 {
4591 Matrix(ss_speed, ss_density, 0);
4592 game_pal();
4593 }
4594 #else
4595 // The reason these are different on Mac in the first place is that
4596 // the OS doesn't let us use F9 and F10...
4597 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4598
4599 if(zc_readkey(KEY_F9))
4600 {
4601 Matrix(ss_speed, ss_density, 0);
4602 game_pal();
4603 }
4604 #endif
4605 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4606 {
4607 //change containers
4608 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4609 {
4610 //magic containers
4611 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4612 {
4613 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4614 }
4615 else
4616 {
4617 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4618 }
4619 }
4620 else
4621 {
4622 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4623 {
4624 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4625 }
4626 else
4627 {
4628 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4629 }
4630 }
4631 }
4632
4633 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4634 {
4635 //change containers
4636 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4637 {
4638 //magic containers
4639 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4640 {
4641 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4642 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4643 //heart containers
4644 }
4645 else
4646 {
4647 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4648 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4649 }
4650 }
4651 else
4652 {
4653 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4654 {
4655 game->set_magic(zc_max(game->get_magic()-1,0));
4656 }
4657 else
4658 {
4659 game->set_life(zc_max(game->get_life()-1,0));
4660 }
4661 }
4662 }
4663
4664 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4665
4666 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4667
4668 verifyBothWeapons();
4669
4670 bottom:
4671
4672
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(input_idle(true) > after_time())
4673 {
4674 Matrix(ss_speed, ss_density, 0);
4675 game_pal();
4676 }
4677 6510614 }
4678
4679 330136 void checkQuitKeys()
4680 {
4681 #ifndef ALLEGRO_MACOSX
4682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4683
4684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4685 #else
4686 if(key[KEY_F7]) f_Quit(qRESET);
4687
4688 if(key[KEY_F8]) f_Quit(qEXIT);
4689 #endif
4690 330136 }
4691
4692 6510614 bool CheatModifierKeys()
4693 {
4694 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4695 // to trigger cheats.
4696
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (replay_is_replaying())
4697 6510614 return false;
4698
4699 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4700 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4701 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4702 {
4703 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4704 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4705 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4706 {
4707 return true;
4708 }
4709 }
4710 return false;
4711 6510614 }
4712
4713 //99:05:54, for some reason?
4714 #define OLDMAXTIME 21405240
4715 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4716 #define MAXTIME 1944000000
4717
4718 6510665 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4719 {
4720
2/2
✓ Branch 0 taken 6242564 times.
✓ Branch 1 taken 268101 times.
6510665 if(zcmusic!=NULL)
4721 {
4722 268101 zcmusic_poll();
4723 268101 }
4724
4725 6510665 updatescr(allowwavy);
4726
4727 6510665 Advance=false;
4728
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6510665 times.
6510665 while(Paused && !Advance && !Quit)
4729 {
4730 // have to call this, otherwise we'll get an infinite loop
4731 syskeys();
4732 if(allowF6Script)
4733 {
4734 FFCore.runF6Engine();
4735 }
4736 throttleFPS();
4737
4738 #ifdef _WIN32
4739
4740 if(use_dwm_flush)
4741 {
4742 do_DwmFlush();
4743 }
4744
4745 #endif
4746
4747 // to keep music playing
4748 if(zcmusic!=NULL)
4749 {
4750 zcmusic_poll();
4751 }
4752
4753 update_hw_screen();
4754 }
4755
4756
2/2
✓ Branch 0 taken 6510624 times.
✓ Branch 1 taken 41 times.
6510665 if(Quit)
4757 41 return;
4758
4759
3/4
✓ Branch 0 taken 6428635 times.
✓ Branch 1 taken 81989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6428635 times.
6510624 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4760 6428635 game->change_time(1);
4761
4762
2/4
✓ Branch 0 taken 6510624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510624 times.
6510624 if (!replay_is_active() || replay_get_version() >= 11)
4763 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4764 down_control_states[i] = raw_control_state[i];
4765
4766
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510622 times.
6510624 if (replay_is_active())
4767 {
4768
2/2
✓ Branch 0 taken 1270461 times.
✓ Branch 1 taken 5240161 times.
6510622 if (replay_get_version() >= 3)
4769 5240161 replay_poll();
4770
4771
5/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3089962 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2989427 times.
6510622 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4772 100535 replay_peek_input();
4773 6510614 }
4774
4775 6510624 load_control_called_this_frame = false;
4776
4777 6510624 poll_keyboard();
4778 6510624 update_keys();
4779
4780 6510624 ++frame;
4781
4782
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4783 6510614 replay_do_cheats();
4784 6510624 syskeys();
4785
4786 // The mouse variables can change from the mouse thread at anytime during a frame,
4787 // so save the result at the start so that replaying is consistent.
4788 6510624 script_mouse_x = gui_mouse_x();
4789 6510624 script_mouse_y = gui_mouse_y();
4790 6510624 script_mouse_z = mouse_z;
4791 6510624 script_mouse_b = mouse_b;
4792
4793 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4794 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4795 // approach here means it doesn't matter which call adds the cheat.
4796 6510624 cheats_execute_queued();
4797
4798
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4799 6510614 replay_peek_quit();
4800
2/2
✓ Branch 0 taken 6510610 times.
✓ Branch 1 taken 14 times.
6510624 if (GameFlags & GAMEFLAG_TRYQUIT)
4801 14 replay_step_quit(0);
4802
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 6508789 times.
6510624 if(allowF6Script)
4803 6508789 FFCore.runF6Engine();
4804
2/2
✓ Branch 0 taken 6510449 times.
✓ Branch 1 taken 175 times.
6510624 if (Quit)
4805 175 replay_step_quit(Quit);
4806 // Someday... maybe install a Turbo button here?
4807 6510624 throttleFPS();
4808
4809 #ifdef _WIN32
4810
4811 if(use_dwm_flush)
4812 {
4813 do_DwmFlush();
4814 }
4815
4816 #endif
4817
4818 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4819
2/2
✓ Branch 0 taken 29901 times.
✓ Branch 1 taken 6480723 times.
6510624 if(sfxcleanup)
4820 6480723 sfx_cleanup();
4821 6510665 }
4822
4823 59 void zapout()
4824 {
4825 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4826 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4827
4828 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4829 59 script_drawing_commands.Clear();
4830
4831 // zap out
4832
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=1; i<=24; i++)
4833 {
4834 1416 draw_fuzzy(i);
4835 1416 advanceframe(true);
4836
4837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4838 {
4839 break;
4840 }
4841 1416 }
4842 59 }
4843
4844 59 void zapin()
4845 {
4846 59 FFCore.warpScriptCheck();
4847 59 draw_screen(tmpscr);
4848 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4849 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4850 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4851
4852 // zap out
4853 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4854
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=24; i>=1; i--)
4855 {
4856 1416 draw_fuzzy(i);
4857 1416 advanceframe(true);
4858
4859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4860 {
4861 break;
4862 }
4863 1416 }
4864 59 }
4865
4866
4867 23 void wavyout(bool showhero)
4868 {
4869 23 draw_screen(tmpscr, showhero);
4870 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4871
4872 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4873 23 clear_to_color(wavebuf,0);
4874 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4875
4876 static PALETTE wavepal;
4877
4878 int32_t ofs;
4879 23 int32_t amplitude=8;
4880
4881 23 int32_t wavelength=4;
4882 23 double palpos=0, palstep=4, palstop=126;
4883
4884 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4885
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4886 {
4887
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4888 {
4889 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4890 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4891 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4892 247296 }
4893
4894 966 palpos+=palstep;
4895
4896
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4897 {
4898 966 hw_palette = &wavepal;
4899 966 update_hw_pal = true;
4900 966 }
4901 else
4902 {
4903 hw_palette = &RAMpal;
4904 update_hw_pal = true;
4905 }
4906
4907
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4908 {
4909
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4910 {
4911 41545728 ofs=0;
4912
4913
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4914 {
4915 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4916 10139136 }
4917
4918 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4919 41545728 }
4920 162288 }
4921
4922 966 advanceframe(true);
4923
4924 // animate_combos();
4925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4926 break;
4927 966 }
4928
4929 23 destroy_bitmap(wavebuf);
4930 23 }
4931
4932 23 void wavyin()
4933 {
4934 23 draw_screen(tmpscr);
4935 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4936
4937 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4938 23 clear_to_color(wavebuf,0);
4939 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4940
4941 static PALETTE wavepal;
4942
4943 //Breaks dark rooms.
4944 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4945 /*
4946 loadfullpal();
4947 loadlvlpal(DMaps[currdmap].color);
4948 ringcolor(false);
4949 */
4950 23 refreshpal=false;
4951 int32_t ofs;
4952 23 int32_t amplitude=8;
4953 23 int32_t wavelength=4;
4954 23 double palpos=168, palstep=4, palstop=126;
4955
4956 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4957
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4958 {
4959
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4960 {
4961 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4962 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4963 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4964 247296 }
4965
4966 966 palpos-=palstep;
4967
4968
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4969 {
4970 966 hw_palette = &wavepal;
4971 966 update_hw_pal = true;
4972 966 }
4973 else
4974 {
4975 hw_palette = &RAMpal;
4976 update_hw_pal = true;
4977 }
4978
4979
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4980 {
4981
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4982 {
4983 41545728 ofs=0;
4984
4985
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4986 {
4987 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4988 10386432 }
4989
4990 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4991 41545728 }
4992 162288 }
4993
4994 966 advanceframe(true);
4995 // animate_combos();
4996
4997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4998 break;
4999 966 }
5000
5001 23 destroy_bitmap(wavebuf);
5002 23 }
5003
5004 1619 void blackscr(int32_t fcnt,bool showsubscr)
5005 {
5006 1619 reset_pal_cycling();
5007 1619 script_drawing_commands.Clear();
5008
5009 1619 FFCore.warpScriptCheck();
5010 1619 bool showtime = game->should_show_time();
5011
2/2
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 48500 times.
50119 while(fcnt>0)
5012 {
5013 48500 clear_bitmap(framebuf);
5014
5015
2/2
✓ Branch 0 taken 13500 times.
✓ Branch 1 taken 35000 times.
48500 if(showsubscr)
5016 {
5017 35000 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5018
3/4
✓ Branch 0 taken 35000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 34250 times.
35000 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5019 {
5020 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5021 750 }
5022 35000 }
5023
5024 48500 advanceframe(true);
5025
5026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48500 times.
48500 if(Quit)
5027 break;
5028
5029 48500 --fcnt;
5030 }
5031 1619 }
5032
5033 563 void openscreen(int32_t shape)
5034 {
5035 563 reset_pal_cycling();
5036 563 black_opening_count=0;
5037
5038
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
563 if(COOLSCROLL || shape>-1)
5039 {
5040 465 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5041 465 return;
5042 }
5043 else
5044 {
5045 98 Hero.setDontDraw(true);
5046 98 show_subscreen_dmap_dots=false;
5047 98 show_subscreen_numbers=false;
5048 // show_subscreen_items=false;
5049 98 show_subscreen_life=false;
5050 }
5051
5052 98 int32_t x=128;
5053
5054 98 FFCore.warpScriptCheck();
5055
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5056 {
5057 7840 draw_screen(tmpscr);
5058 //? draw_screen already draws the subscreen -DD
5059 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5060 7840 x=128-(((i*128/80)/8)*8);
5061
5062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5063 {
5064 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5065 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5066 7840 }
5067
5068 7840 advanceframe(true);
5069
5070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5071 {
5072 break;
5073 }
5074 7840 }
5075
5076 98 Hero.setDontDraw(false);
5077 98 show_subscreen_items=true;
5078 98 show_subscreen_dmap_dots=true;
5079 563 }
5080
5081 void closescreen(int32_t shape)
5082 {
5083 reset_pal_cycling();
5084 black_opening_count=0;
5085
5086 if(COOLSCROLL || shape>-1)
5087 {
5088 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5089 return;
5090 }
5091 else
5092 {
5093 Hero.setDontDraw(true);
5094 show_subscreen_dmap_dots=false;
5095 show_subscreen_numbers=false;
5096 // show_subscreen_items=false;
5097 show_subscreen_life=false;
5098 }
5099
5100 int32_t x=128;
5101
5102 FFCore.warpScriptCheck();
5103 for(int32_t i=79; i>=0; --i)
5104 {
5105 draw_screen(tmpscr);
5106 //? draw_screen already draws the subscreen -DD
5107 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5108 x=128-(((i*128/80)/8)*8);
5109
5110 if(x>0)
5111 {
5112 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5113 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5114 }
5115
5116 advanceframe(true);
5117
5118 if(Quit)
5119 {
5120 break;
5121 }
5122 }
5123
5124 Hero.setDontDraw(false);
5125 show_subscreen_items=true;
5126 show_subscreen_dmap_dots=true;
5127 }
5128
5129 122 int32_t TriforceCount()
5130 {
5131 122 int32_t c=0;
5132
5133
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 122 times.
1098 for(int32_t i=1; i<=8; i++)
5134
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 650 times.
1626 if(game->lvlitems[i]&liTRIFORCE)
5135 650 ++c;
5136
5137 122 return c;
5138 }
5139
5140 int32_t onCustomGame()
5141 {
5142 int32_t file = getsaveslot();
5143
5144 if(file < 0)
5145 return D_O_K;
5146
5147 bool ret = (custom_game(file)!=0);
5148 return ret ? D_CLOSE : D_O_K;
5149 }
5150
5151 int32_t onContinue()
5152 {
5153 return D_CLOSE;
5154 }
5155
5156 int32_t onEsc() // Unused?? -L
5157 {
5158 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5159 }
5160
5161 int32_t onVsync()
5162 {
5163 Throttlefps = !Throttlefps;
5164 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5165 return D_O_K;
5166 }
5167
5168 int32_t onWinPosSave()
5169 {
5170 SaveWinPos = !SaveWinPos;
5171 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5172 return D_O_K;
5173 }
5174 int32_t onIntegerScaling()
5175 {
5176 scaleForceInteger = !scaleForceInteger;
5177 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5178 return D_O_K;
5179 }
5180
5181 int32_t onClickToFreeze()
5182 {
5183 ClickToFreeze = !ClickToFreeze;
5184 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5185 return D_O_K;
5186 }
5187
5188 int32_t OnSaveZCConfig()
5189 {
5190 if(jwin_alert3(
5191 "Save Configuration",
5192 "Are you sure that you wish to save your present configuration settings?",
5193 "This will overwrite your prior settings!",
5194 NULL,
5195 "&Yes",
5196 "&No",
5197 NULL,
5198 'y',
5199 'n',
5200 0,
5201 lfont) == 1)
5202 {
5203 save_game_configs();
5204 return D_O_K;
5205 }
5206 else return D_O_K;
5207 }
5208
5209 int32_t OnnClearQuestDir()
5210 {
5211 if(jwin_alert3(
5212 "Clear Current Directory Cache",
5213 "Are you sure that you wish to clear the current cached directory?",
5214 "This will default the current directory to the ROOT for this instance of ZC Player!",
5215 NULL,
5216 "&Yes",
5217 "&No",
5218 NULL,
5219 'y',
5220 'n',
5221 0,
5222 lfont) == 1)
5223 {
5224 zc_set_config("zeldadx","win_qst_dir","");
5225 flush_config_file();
5226 strcpy(qstdir,"");
5227 #ifdef __EMSCRIPTEN__
5228 em_sync_fs();
5229 #endif
5230 return D_O_K;
5231 }
5232 else return D_O_K;
5233 }
5234
5235
5236 int32_t onConsoleZASM()
5237 {
5238 if ( !zasm_debugger )
5239 {
5240 AlertDialog("WARNING: ZASM Debugger",
5241 "Enabling this will open the ZASM Debugger Console"
5242 "\nThis will likely grind ZC to a halt with lag."
5243 "\nTo make any use of this, it is suggested that you read"
5244 "\nthe documentation for 'void Breakpoint(char[] string);'"
5245 " in 'ZScript_Additions.txt'"
5246 "\nThis is not recommended for normal users,"
5247 " and is only intended for ZC developers,"
5248 "\nor quest developers coding directly in ZASM"
5249 "\nAre you sure that you wish to open the ZASM Debugger?",
5250 [&](bool ret,bool)
5251 {
5252 if(ret)
5253 {
5254 FFCore.ZASMPrint(true);
5255 }
5256 }).show();
5257 return D_O_K;
5258 }
5259 else
5260 {
5261 FFCore.ZASMPrint(false);
5262 return D_O_K;
5263 }
5264 }
5265
5266
5267 int32_t onConsoleZScript()
5268 {
5269 if ( !zscript_debugger )
5270 {
5271 AlertDialog("ZScript Debugger",
5272 "Enabling this will open the ZScript Debugger Console"
5273 "\nThis will display any messages logged by scripts,"
5274 " including script errors."
5275 "\nAre you sure that you wish to open the ZScript Debugger?",
5276 [&](bool ret,bool)
5277 {
5278 if(ret)
5279 {
5280 FFCore.ZScriptConsole(true);
5281 }
5282 }).show();
5283 return D_O_K;
5284 }
5285 else
5286 {
5287 FFCore.ZScriptConsole(false);
5288 return D_O_K;
5289 }
5290 }
5291
5292 int32_t onClrConsoleOnReload()
5293 {
5294 clearConsoleOnReload = !clearConsoleOnReload;
5295 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5296 return D_O_K;
5297 }
5298 int32_t onClrConsoleOnLoad()
5299 {
5300 clearConsoleOnLoad = !clearConsoleOnLoad;
5301 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5302 return D_O_K;
5303 }
5304
5305
5306 int32_t onFrameSkip()
5307 {
5308 FrameSkip = !FrameSkip;
5309 return D_O_K;
5310 }
5311
5312 int32_t onSaveDragResize()
5313 {
5314 SaveDragResize = !SaveDragResize;
5315 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5316 return D_O_K;
5317 }
5318
5319 int32_t onDragAspect()
5320 {
5321 DragAspect = !DragAspect;
5322 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5323 return D_O_K;
5324 }
5325
5326 int32_t onTransLayers()
5327 {
5328 TransLayers = !TransLayers;
5329 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5330 return D_O_K;
5331 }
5332
5333 int32_t onNESquit()
5334 {
5335 NESquit = !NESquit;
5336 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5337 return D_O_K;
5338 }
5339
5340 int32_t onVolKeys()
5341 {
5342 volkeys = !volkeys;
5343 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5344 return D_O_K;
5345 }
5346
5347 int32_t onShowFPS()
5348 {
5349 ShowFPS = !ShowFPS;
5350 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5351 return D_O_K;
5352 }
5353
5354 768252452 bool is_Fkey(int32_t k)
5355 {
5356
2/2
✓ Branch 0 taken 78127368 times.
✓ Branch 1 taken 690125084 times.
768252452 switch(k)
5357 {
5358 case KEY_F1:
5359 case KEY_F2:
5360 case KEY_F3:
5361 case KEY_F4:
5362 case KEY_F5:
5363 case KEY_F6:
5364 case KEY_F7:
5365 case KEY_F8:
5366 case KEY_F9:
5367 case KEY_F10:
5368 case KEY_F11:
5369 case KEY_F12:
5370 78127368 return true;
5371 }
5372
5373 690125084 return false;
5374 768252452 }
5375
5376 void kb_getkey(DIALOG *d);
5377
5378 //Used by all keyboard key settings dialogues.
5379 void kb_clearjoystick(DIALOG *d)
5380 {
5381 d->flags|=D_SELECTED;
5382
5383 scare_mouse();
5384 jwin_button_proc(MSG_DRAW,d,0);
5385 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5386 // text_mode(vc(11));
5387 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5388 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5389 unscare_mouse();
5390
5391 update_hw_screen(true);
5392
5393 clear_keybuf();
5394 int32_t k = next_press_key();
5395 clear_keybuf();
5396
5397 //shnarf
5398 //47=f1
5399 //59=esc
5400 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5401 // *((int32_t*)d->dp3) = k;
5402 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5403
5404
5405 d->flags&=~D_SELECTED;
5406 }
5407
5408 //Clears key to 0.
5409 //Used by all keyboard key settings dialogues.
5410 void kb_clearkey(DIALOG *d);
5411
5412 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5413 {
5414 switch(msg)
5415 {
5416 case MSG_KEY:
5417 case MSG_CLICK:
5418
5419 kb_clearjoystick(d);
5420
5421 while(gui_mouse_b())
5422 {
5423 clear_keybuf();
5424 rest(1);
5425 }
5426
5427 return D_REDRAW;
5428 }
5429
5430 return jwin_button_proc(msg,d,c);
5431 }
5432
5433 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5434 //Only used in keyboard settings dialogues to clear keys.
5435 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5436
5437 void j_getbtn(DIALOG *d)
5438 {
5439 d->flags|=D_SELECTED;
5440 scare_mouse();
5441 jwin_button_proc(MSG_DRAW,d,0);
5442 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5443 // text_mode(vc(11));
5444 int32_t y = gui_bmp->h/2 - 12;
5445 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5446 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5447 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5448 unscare_mouse();
5449
5450 update_hw_screen(true);
5451
5452 int32_t b = next_press_btn();
5453
5454 if(b>=0)
5455 *((int32_t*)d->dp3) = b;
5456
5457 d->flags&=~D_SELECTED;
5458
5459 if (player)
5460 player->joy_on = TRUE;
5461 }
5462
5463 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5464 {
5465 switch(msg)
5466 {
5467 case MSG_KEY:
5468 case MSG_CLICK:
5469
5470 j_getbtn(d);
5471
5472 while(gui_mouse_b()) {
5473 rest(1);
5474 clear_keybuf();
5475 }
5476
5477 return D_REDRAW;
5478 }
5479
5480 return jwin_button_proc(msg,d,c);
5481 }
5482
5483 //shnarf
5484 extern const char *key_str[];
5485 std::string get_keystr(int key);
5486
5487 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5488 //extern int32_t zcmusic_bufsz;
5489
5490 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5491 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5492
5493 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5494 {
5495 //these are here to bypass compiler warnings about unused arguments
5496 c=c;
5497
5498 if(msg==MSG_DRAW)
5499 {
5500 switch(d->w)
5501 {
5502 case 0:
5503 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5504 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5505 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5506 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5507 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5508 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5509 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5510 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5511 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5512 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5513 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5514 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5515 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5516 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5517 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5518 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5519 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5520 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5521 break;
5522
5523 case 1:
5524 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5525 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5526 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5527 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5528 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5529 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5530 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5531 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5532 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5533 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5534 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5535 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5536 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5537 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5538 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5539 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5540 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5541 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5542 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5543 break;
5544
5545 case 2:
5546 sprintf(str_a," %3d",midi_volume);
5547 sprintf(str_b," %3d",digi_volume);
5548 sprintf(str_l," %3d",emusic_volume);
5549 sprintf(str_m," %3dKB",zcmusic_bufsz);
5550 sprintf(str_r," %3d",sfx_volume);
5551 strcpy(str_s,pan_str[pan_style]);
5552 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5553 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5554 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5555 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5556 break;
5557 }
5558 }
5559
5560 return D_O_K;
5561 }
5562
5563 int32_t set_vol(void *dp3, int32_t d2)
5564 {
5565 switch(((int32_t*)dp3)[0])
5566 {
5567 case 0:
5568 midi_volume = zc_min(d2<<3,255);
5569 break;
5570
5571 case 1:
5572 digi_volume = zc_min(d2<<3,255);
5573 break;
5574
5575 case 2:
5576 emusic_volume = zc_min(d2<<3,255);
5577 break;
5578
5579 case 3:
5580 sfx_volume = zc_min(d2<<3,255);
5581 break;
5582 }
5583
5584 scare_mouse();
5585 // text_mode(vc(11));
5586 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5587 unscare_mouse();
5588 return D_O_K;
5589 }
5590
5591 int32_t set_pan(void *dp3, int32_t d2)
5592 {
5593 pan_style = vbound(d2,0,3);
5594 scare_mouse();
5595 // text_mode(vc(11));
5596 textout_right_ex(screen,lfont_l, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5597 unscare_mouse();
5598 return D_O_K;
5599 }
5600
5601 int32_t set_buf(void *dp3, int32_t d2)
5602 {
5603 scare_mouse();
5604 // text_mode(vc(11));
5605 zcmusic_bufsz = d2 + 1;
5606 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5607 unscare_mouse();
5608 return D_O_K;
5609 }
5610
5611 static int32_t gamepad_btn_list[] =
5612 {
5613 6,
5614 7,8,9,10,11,12,13,14,15,16,17,
5615 18,19,20,21,22,23,24,25,26,27,28,
5616 29,30,31,32,33,34,35,36,37,38,39,
5617 -1
5618 };
5619
5620 static int32_t gamepad_dirs_list[] =
5621 {
5622 40,41,42,43,
5623 44,45,46,47,
5624 48,49,50,51,
5625 52,53,54,55,
5626 56,
5627 -1
5628 };
5629
5630 static TABPANEL gamepad_tabs[] =
5631 {
5632 // (text)
5633 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5634 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5635 { NULL, 0, NULL, 0, NULL }
5636 };
5637
5638 static DIALOG gamepad_dlg[] =
5639 {
5640 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5641 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5642 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5643 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5644 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5645 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5646 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5647 // 6
5648 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5649 // 7
5650 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5651 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5652 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5653 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5654 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5655 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5656 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5657 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5658 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5659 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5660 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5661 // 18
5662 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5663 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5664 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5665 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5666 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5667 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5668 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5669 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5670 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5671 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5672 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5673 // 29
5674 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5675 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5676 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5677 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5678 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5679 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5680 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5681 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5682 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5683 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5684 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5685 // 40
5686 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5687 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5688 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5689 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5690 // 44
5691 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5692 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5693 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5694 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5695 // 48
5696 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5697 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5698 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5699 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5700 // 52
5701 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5702 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5703 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5704 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5705 // 56
5706 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5707 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5708 };
5709
5710 static int32_t keyboard_keys_list[] =
5711 {
5712 6,7,8,9,10,
5713 11,12,13,14,15,16,17,18,19,20,
5714 21,22,23,24,25,26,27,28,29,30,
5715 31,32,33,34,35,36,37,38,39,40,
5716 -1
5717 };
5718
5719 static int32_t keyboard_dirs_list[] =
5720 {
5721 41,42,43,44,
5722 45,46,47,48,
5723 49,50,51,52,
5724 53,54,55,56,
5725 -1
5726 };
5727
5728 static int32_t keyboard_mods_list[] =
5729 {
5730 57,58,59,60,
5731 61,62,63,64,
5732 65,66,67,68,
5733 69,70,71,72,
5734 -1
5735 };
5736
5737 static TABPANEL keyboard_control_tabs[] =
5738 {
5739 // (text)
5740 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5741 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5742 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5743 { NULL, 0, NULL, 0, NULL }
5744 };
5745
5746 static DIALOG keyboard_control_dlg[] =
5747 {
5748 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5749 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5750 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5751 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5752 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5753 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5754 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5755 // Keys
5756 // 6
5757 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5758 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5759 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5760 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5761 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5762 // 11
5763 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5764 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5765 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5766 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5767 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5768 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5769 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5770 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5771 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5772 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5773 // 21
5774 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5775 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5776 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5777 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5778 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5779 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5780 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5781 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5782 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5783 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5784 // 31
5785 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5786 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5787 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5788 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5789 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5790 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5791 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5792 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5793 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5794 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5795 // Dirs
5796 // 41
5797 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5798 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5799 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5800 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5801 // 45
5802 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5803 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5804 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5805 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5806 // 49
5807 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5808 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5809 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5810 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5811 // 53
5812 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5813 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5814 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5815 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5816 // Mods
5817 // 57
5818 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5819 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5820 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5821 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5822 // 61
5823 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5824 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5825 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5826 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5827 // 65
5828 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5829 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5830 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5831 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5832 // 69
5833 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5834 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5835 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5836 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5837 // 73
5838 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5839 };
5840
5841 /*
5842 int32_t midi_dp[3] = {0,147,104};
5843 int32_t digi_dp[3] = {1,147,120};
5844 int32_t pan_dp[3] = {0,147,136};
5845 int32_t buf_dp[3] = {0,147,152};
5846 */
5847 int32_t midi_dp[3] = {0,0,0};
5848 int32_t digi_dp[3] = {1,0,0};
5849 int32_t emus_dp[3] = {2,0,0};
5850 int32_t buf_dp[3] = {0,0,0};
5851 int32_t sfx_dp[3] = {3,0,0};
5852 int32_t pan_dp[3] = {0,0,0};
5853
5854 static DIALOG sound_dlg[] =
5855 {
5856 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5857 29 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5858 29 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5859 29 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5860 29 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5861 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5862 29 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5863 29 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5864 29 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5865 29 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5866 29 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5867 // 10
5868 29 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5869 29 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5870 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5871 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5872 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5873 29 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5874 29 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5875 29 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5876 29 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5877 29 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5878 //20
5879 29 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5880 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5881 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5882 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5883 29 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5884 29 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5885 29 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5886 29 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5887 29 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5888 29 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5889 //30
5890 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5891 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5892 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5893 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5894 };
5895
5896 char zc_builddate[80];
5897 char zc_aboutstr[80];
5898
5899 static DIALOG about_dlg[] =
5900 {
5901 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5902 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5903 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5904 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5905 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5906 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5907 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5908 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5909 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5910 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5911 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5912 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5913 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5914 };
5915
5916
5917 static DIALOG quest_dlg[] =
5918 {
5919 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5920 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5921 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5922 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5923 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5924 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5925 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5926 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5927 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5928 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5929 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5930 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5931 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5932 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5933 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5934 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5935 };
5936
5937 static DIALOG triforce_dlg[] =
5938 {
5939 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5940 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5941 // 1
5942 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5943 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5944 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5945 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5946 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5947 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5948 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5949 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5950 // 9
5951 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5952 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5953 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5954 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5955 };
5956
5957 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5958 {
5959 go();
5960 int32_t ret=0;
5961 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5962 comeback();
5963 return ret != 0;
5964 }
5965
5966
5967 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5968 {
5969 if(def!=modulepath)
5970 strcpy(modulepath,def);
5971
5972 if(!usefilename)
5973 {
5974 int32_t i=(int32_t)strlen(modulepath);
5975
5976 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5977 modulepath[i--]=0;
5978 }
5979
5980 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5981 int32_t ret=0;
5982 int32_t sel=0;
5983
5984 if(list==NULL)
5985 {
5986 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
5987 }
5988 else
5989 {
5990 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
5991 }
5992
5993 return ret!=0;
5994 }
5995
5996 //The Dialogue that loads a ZMOD Module File
5997 int32_t zc_load_zmod_module_file()
5998 {
5999 if ( Playing )
6000 {
6001 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6002 return -1;
6003 }
6004 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6005 return D_CLOSE;
6006
6007 FILE *tempmodule = fopen(modulepath,"r");
6008
6009 if(tempmodule == NULL)
6010 {
6011 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6012 return -1;
6013 }
6014
6015
6016 //Set the module path:
6017 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6018 strcpy(moduledata.module_name, modulepath);
6019 al_trace("New Module Path is: %s \n", moduledata.module_name);
6020 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6021 zcm.init(true); //Load the module values.
6022 moduledata.refresh_title_screen = 1;
6023 // refresh_select_screen = 1;
6024 build_biic_list();
6025 return D_O_K;
6026 }
6027
6028 static DIALOG module_info_dlg[] =
6029 {
6030 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6031
6032
6033 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6034 //1
6035 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6036 //2
6037 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6038 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6039 //4
6040 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6041 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6042 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6043 //7
6044
6045 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6046 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6047 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6048 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6049 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6050 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6051 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6052 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6053 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6054
6055 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6056 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6057 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6058 };
6059
6060 void about_zcplayer_module(const char *prompt,int32_t initialval)
6061 {
6062
6063 module_info_dlg[0].dp2 = lfont;
6064 if ( moduledata.moduletitle[0] != 0 )
6065 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6066
6067 if ( moduledata.moduleauthor[0] != 0 )
6068 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6069
6070 if ( moduledata.moduleinfo0[0] != 0 )
6071 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6072 if ( moduledata.moduleinfo1[0] != 0 )
6073 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6074 if ( moduledata.moduleinfo2[0] != 0 )
6075 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6076 if ( moduledata.moduleinfo3[0] != 0 )
6077 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6078 if ( moduledata.moduleinfo4[0] != 0 )
6079 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6080
6081 char module_date[255];
6082 memset(module_date, 0, sizeof(module_date));
6083 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6084 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6085
6086
6087
6088 char module_vers[255];
6089 memset(module_vers, 0, sizeof(module_vers));
6090 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6091
6092
6093 //sprintf(tilecount,"%d",1);
6094
6095 char module_build[255];
6096 memset(module_build, 0, sizeof(module_build));
6097 if ( moduledata.modbeta )
6098 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6099 else
6100 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6101
6102 module_info_dlg[12].dp = (char*)module_date;
6103 module_info_dlg[13].dp = (char*)module_vers;
6104 module_info_dlg[14].dp = (char*)module_build;
6105
6106 large_dialog(module_info_dlg);
6107
6108 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6109 jwin_center_dialog(module_info_dlg);
6110
6111
6112 }
6113
6114 int32_t onAbout_ZCP_Module()
6115 {
6116 about_zcplayer_module("About Module (.zmod)", 0);
6117 return D_O_K;
6118 }
6119
6120 //New Modules Menu for 2.55+
6121 static MENU zcmodule_menu[] =
6122 {
6123 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6124 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6125
6126 { NULL, NULL, NULL, 0, NULL }
6127 };
6128
6129 int32_t onToggleRecordingNewSaves()
6130 {
6131 if (zc_get_config("zeldadx", "replay_new_saves", false))
6132 {
6133 zc_set_config("zeldadx", "replay_new_saves", false);
6134 }
6135 else
6136 {
6137 zc_set_config("zeldadx", "replay_new_saves", true);
6138 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6139 NULL,NULL,"OK",NULL,13,27,lfont);
6140 }
6141 return D_O_K;
6142 }
6143
6144 int32_t onToggleSnapshotAllFrames()
6145 {
6146 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6147 return D_O_K;
6148 }
6149
6150 int32_t onStopReplayOrRecord()
6151 {
6152 if (replay_is_replaying())
6153 {
6154 replay_quit();
6155 }
6156 else if (replay_get_mode() == ReplayMode::Record)
6157 {
6158 if (!replay_get_meta_bool("test_mode"))
6159 {
6160 jwin_alert("Recording", "You cannot stop recording a save file.",
6161 NULL,NULL,"OK",NULL,13,27,lfont);
6162 return D_CLOSE;
6163 }
6164
6165 if (jwin_alert("Stop Recording",
6166 "Save replay to disk and stop recording?",
6167 "This will stop the recording.",
6168 NULL,
6169 "Yes","No",13,27,lfont) != 1)
6170 return D_CLOSE;
6171
6172 replay_save();
6173 replay_stop();
6174 }
6175 return D_O_K;
6176 }
6177
6178 static int32_t handle_on_load_replay(ReplayMode mode)
6179 {
6180 if (Playing)
6181 {
6182 if (jwin_alert("Replay - Warning!",
6183 "Loading a replay will exit the current game.",
6184 "All unsaved progress will be lost.",
6185 "Do you wish to continue?",
6186 "Yes","No",13,27,lfont) != 1)
6187 return D_CLOSE;
6188 }
6189
6190 std::string mode_string = replay_mode_to_string(mode);
6191 mode_string[0] = std::toupper(mode_string[0]);
6192
6193 std::string line_1 = "Select a replay file to play back.";
6194 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6195 std::string line_3 = "You can stop the replay and take over manually any time.";
6196 if (mode == ReplayMode::Update)
6197 {
6198 line_1 = "Select a replay file to update.";
6199 line_2 = "WARNING: be sure to back up the zplay file";
6200 line_3 = "and verify that the updated replay works as expected!";
6201 }
6202
6203 if (jwin_alert(mode_string.c_str(),
6204 line_1.c_str(),
6205 line_2.c_str(),
6206 line_3.c_str(),
6207 "OK","Nevermind",13,27,lfont) == 1)
6208 {
6209 char replay_path[2048];
6210 strcpy(replay_path, "replays/");
6211 if (jwin_file_select_ex(
6212 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6213 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6214 return D_CLOSE;
6215
6216 replay_quit();
6217 load_replay_file_deferred(mode, replay_path);
6218 Quit = qRESET;
6219 return D_CLOSE;
6220 }
6221 return D_O_K;
6222 }
6223
6224 int32_t onLoadReplay()
6225 {
6226 return handle_on_load_replay(ReplayMode::Replay);
6227 }
6228
6229 int32_t onLoadReplayAssert()
6230 {
6231 return handle_on_load_replay(ReplayMode::Assert);
6232 }
6233
6234 int32_t onLoadReplayUpdate()
6235 {
6236 return handle_on_load_replay(ReplayMode::Update);
6237 }
6238
6239 int32_t onSaveReplay()
6240 {
6241 if (replay_get_mode() == ReplayMode::Record)
6242 {
6243 if (!replay_get_meta_bool("test_mode"))
6244 {
6245 if (jwin_alert("Save Replay",
6246 "This will save a copy of the replay up to this point.",
6247 "The official replay file will be untouched.",
6248 "Do you wish to continue?",
6249 "Yes","No",13,27,lfont) != 1)
6250 return D_CLOSE;
6251
6252 char replay_path[2048];
6253 strcpy(replay_path, replay_get_replay_path().string().c_str());
6254 if (jwin_file_select_ex(
6255 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6256 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6257 return D_CLOSE;
6258
6259 if (fileexists(replay_path))
6260 {
6261 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6262 NULL,NULL,"OK",NULL,13,27,lfont);
6263 return D_CLOSE;
6264 }
6265
6266 replay_save(replay_path);
6267 }
6268 else
6269 {
6270 replay_save();
6271 }
6272 }
6273 return D_O_K;
6274 }
6275
6276 static MENU replay_menu[] =
6277 {
6278 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6279 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6280 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6281 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6282 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6283 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6284 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6285
6286 { NULL, NULL, NULL, 0, NULL }
6287 };
6288
6289 static DIALOG credits_dlg[] =
6290 {
6291 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6292 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6293 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6294 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6295 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6296 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6297 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6298 };
6299
6300 29 static ListData dmap_list(dmaplist, &font);
6301
6302 static DIALOG goto_dlg[] =
6303 {
6304 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6305 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6306 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6307 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6308 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6309 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6310 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6311 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6312 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6313 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6314 };
6315
6316 int32_t onGoTo()
6317 {
6318 bool music = false;
6319 music = music;
6320 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6321
6322 goto_dlg[0].dp2=lfont;
6323 goto_dlg[4].d2=cheat_goto_dmap;
6324 goto_dlg[6].dp=cheat_goto_screen_str;
6325
6326 clear_keybuf();
6327
6328 large_dialog(goto_dlg);
6329
6330 if(zc_popup_dialog(goto_dlg,4)==1)
6331 {
6332 // dmap, screen
6333 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6334 };
6335
6336 return D_O_K;
6337 }
6338
6339 int32_t onGoToComplete()
6340 {
6341 if(!Playing)
6342 {
6343 return D_O_K;
6344 }
6345
6346 system_pal();
6347 music_pause();
6348 pause_all_sfx();
6349 show_mouse(screen);
6350 onGoTo();
6351 eat_buttons();
6352
6353 zc_readrawkey(KEY_ESC);
6354
6355 show_mouse(NULL);
6356 game_pal();
6357 music_resume();
6358 resume_all_sfx();
6359 return D_O_K;
6360 }
6361
6362 int32_t onCredits()
6363 {
6364 go();
6365
6366 BITMAP *win = create_bitmap_ex(8,222,110);
6367
6368 if(!win)
6369 return D_O_K;
6370
6371 int32_t c=0;
6372 int32_t l=0;
6373 int32_t ol=-1;
6374 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6375 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6376 PALETTE tmppal;
6377
6378 rti_gui.transparency_index = 1;
6379
6380 clear_to_color(win, rti_gui.transparency_index);
6381 draw_rle_sprite(win,rle,0,0);
6382 credits_dlg[0].dp2=lfont;
6383 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6384 credits_dlg[2].dp = win;
6385
6386 set_palette_range(black_palette,0,127,false);
6387
6388 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6389
6390 BITMAP* old_screen = screen;
6391 BITMAP* gui_bmp = zc_get_gui_bmp();
6392 ASSERT(gui_bmp);
6393 clear_to_color(gui_bmp, rti_gui.transparency_index);
6394 screen = gui_bmp;
6395
6396 while(update_dialog(p))
6397 {
6398 throttleFPS();
6399 ++c;
6400 l = zc_max((c>>1)-30,0);
6401
6402 if(l > rle->h)
6403 l = c = 0;
6404
6405 if(l > rle->h - 112)
6406 l = rle->h - 112;
6407
6408 clear_bitmap(win);
6409 draw_rle_sprite(win,rle,0,0-l);
6410
6411 if(c<=64)
6412 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6413
6414 set_palette_range(tmppal,0,127,false);
6415
6416 if(l!=ol)
6417 {
6418 scare_mouse();
6419 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6420 unscare_mouse();
6421 SCRFIX();
6422 ol=l;
6423 }
6424
6425 update_hw_screen();
6426 }
6427
6428 screen = old_screen;
6429 system_pal();
6430
6431 shutdown_dialog(p);
6432 destroy_bitmap(win);
6433 //comeback();
6434
6435 rti_gui.transparency_index = 0;
6436
6437 return D_O_K;
6438 }
6439
6440 const char *midilist(int32_t index, int32_t *list_size)
6441 {
6442 if(index<0)
6443 {
6444 *list_size=0;
6445
6446 for(int32_t i=0; i<MAXMIDIS; i++)
6447 if(tunes[i].data)
6448 ++(*list_size);
6449
6450 return NULL;
6451 }
6452
6453 int32_t i=0,m=0;
6454
6455 while(m<=index && i<=MAXMIDIS)
6456 {
6457 if(tunes[i].data)
6458 ++m;
6459
6460 ++i;
6461 }
6462
6463 --i;
6464
6465 if(i==MAXMIDIS && m<index)
6466 return "(null)";
6467
6468 return tunes[i].title;
6469 }
6470
6471 /* ------- MIDI info stuff -------- */
6472
6473 char *text;
6474 midi_info *zmi;
6475 bool dialog_running;
6476 bool listening;
6477
6478 void get_info(int32_t index);
6479
6480 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6481 {
6482 int32_t d2 = d->d2;
6483 int32_t ret = jwin_droplist_proc(msg,d,c);
6484
6485 if(d2!=d->d2)
6486 {
6487 get_info(d->d2);
6488 }
6489
6490 return ret;
6491 }
6492
6493 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6494 {
6495 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6496
6497 int32_t ret = jwin_button_proc(msg,d,c);
6498
6499 if(ret == D_CLOSE)
6500 {
6501 // get current midi index
6502 int32_t index = (d+(d->d1))->d2;
6503 int32_t i=0, m=0;
6504
6505 while(m<=index && i<=MAXMIDIS)
6506 {
6507 if(tunes[i].data)
6508 ++m;
6509
6510 ++i;
6511 }
6512
6513 --i;
6514 jukebox(i);
6515 listening = true;
6516 ret = D_O_K;
6517 }
6518
6519 return ret;
6520 }
6521
6522 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6523 {
6524 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6525
6526 int32_t ret = jwin_button_proc(msg,d,c);
6527
6528 if(ret == D_CLOSE)
6529 {
6530 // get current midi index
6531 int32_t index = (d+(d->d1))->d2;
6532 int32_t i=0, m=0;
6533
6534 while(m<=index && i<=MAXMIDIS)
6535 {
6536 if(tunes[i].data)
6537 ++m;
6538
6539 ++i;
6540 }
6541
6542 --i;
6543
6544 // get file name
6545
6546 int32_t sel=0;
6547 //struct ffblk f;
6548 char title[40] = "Save MIDI: ";
6549 char fname[2048];
6550 memset(fname,0,2048);
6551 static EXT_LIST list[] =
6552 {
6553 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6554 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6555 { NULL, NULL }
6556 };
6557
6558 strcpy(title+11, tunes[i].title);
6559 title[39] = '\0';
6560
6561 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6562 goto done;
6563
6564 if(exists(fname))
6565 {
6566 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6567 goto done;
6568 }
6569
6570 // save midi i
6571
6572 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6573 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6574
6575 done:
6576 chop_path(fname);
6577 ret = D_REDRAW;
6578 }
6579
6580 return ret;
6581 }
6582
6583 29 static ListData midi_list(midilist, &font);
6584
6585 static DIALOG midi_dlg[] =
6586 {
6587 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6588 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6589 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6590 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6591 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6592 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6593 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6594 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6595 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6596 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6597 };
6598
6599 void get_info(int32_t index)
6600 {
6601 int32_t i=0, m=0;
6602
6603 while(m<=index && i<=MAXMIDIS)
6604 {
6605 if(tunes[i].data)
6606 ++m;
6607
6608 ++i;
6609 }
6610
6611 --i;
6612
6613 if(i==MAXMIDIS && m<index)
6614 strcpy(text,"(null)");
6615 else
6616 {
6617 get_midi_info((MIDI*)tunes[i].data,zmi);
6618 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6619 }
6620
6621 midi_dlg[0].dp2=lfont;
6622 midi_dlg[3].dp = text;
6623 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6624 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6625
6626 if(dialog_running)
6627 {
6628 scare_mouse();
6629 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6630 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6631 unscare_mouse();
6632 }
6633 }
6634
6635 int32_t onMIDICredits()
6636 {
6637 text = (char*)malloc(4096);
6638 zmi = (midi_info*)malloc(sizeof(midi_info));
6639
6640 if(!text || !zmi)
6641 {
6642 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6643 return D_O_K;
6644 }
6645
6646 bool do_pause_midi = midi_pos >= 0 && currmidi;
6647 auto restore_midi = currmidi;
6648 if(do_pause_midi)
6649 {
6650 paused_midi_pos = midi_pos;
6651 stop_midi();
6652 midi_paused=true;
6653 midi_suspended = midissuspHALTED;
6654 }
6655
6656 midi_dlg[0].dp2=lfont;
6657 midi_dlg[2].d1 = 0;
6658 midi_dlg[2].d2 = 0;
6659 midi_dlg[4].flags = D_EXIT;
6660 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6661
6662 listening = false;
6663 dialog_running=false;
6664 get_info(0);
6665
6666 dialog_running=true;
6667
6668 large_dialog(midi_dlg);
6669
6670 zc_popup_dialog(midi_dlg,0);
6671 dialog_running=false;
6672
6673 if(listening)
6674 music_stop();
6675
6676 if(do_pause_midi)
6677 {
6678 midi_suspended = midissuspRESUME;
6679 currmidi = restore_midi;
6680 midi_pos = paused_midi_pos;
6681 }
6682
6683 if(text) free(text);
6684 if(zmi) free(zmi);
6685 return D_O_K;
6686 }
6687
6688 int32_t onAbout()
6689 {
6690 char buf1[80]={0};
6691 std::ostringstream oss;
6692 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6693 oss << buf1 << '\n';
6694 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6695 oss << buf1 << '\n';
6696 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6697 oss << buf1 << '\n';
6698 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6699 oss << buf1 << '\n';
6700 sprintf(buf1, "Tag: %s", getReleaseTag());
6701 oss << buf1 << '\n';
6702
6703 InfoDialog("About ZC", oss.str()).show();
6704 return D_O_K;
6705 }
6706
6707 int32_t onQuest()
6708 {
6709 char fname[100];
6710 strcpy(fname, get_filename(qstpath));
6711 quest_dlg[0].dp2=lfont;
6712 quest_dlg[1].dp = fname;
6713
6714 if(QHeader.quest_number==0)
6715 sprintf(str_a,"Custom");
6716 else
6717 sprintf(str_a,"%d",QHeader.quest_number);
6718
6719 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6720
6721 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6722 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6723
6724 large_dialog(quest_dlg);
6725
6726 zc_popup_dialog(quest_dlg, 0);
6727 return D_O_K;
6728 }
6729
6730 void call_vidmode_dlg();
6731 int32_t onVidMode()
6732 {
6733 call_vidmode_dlg();
6734 return D_O_K;
6735 }
6736
6737 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6738 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6739 //Added an extra statement, so that if the key is cleared to 0, the cleared
6740 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6741
6742 void load_ukeys(int32_t* arr)
6743 {
6744 arr[ukey_a] = Akey;
6745 arr[ukey_b] = Bkey;
6746 arr[ukey_s] = Skey;
6747 arr[ukey_l] = Lkey;
6748 arr[ukey_r] = Rkey;
6749 arr[ukey_p] = Pkey;
6750 arr[ukey_ex1] = Exkey1;
6751 arr[ukey_ex2] = Exkey2;
6752 arr[ukey_ex3] = Exkey3;
6753 arr[ukey_ex4] = Exkey4;
6754 arr[ukey_du] = DUkey;
6755 arr[ukey_dd] = DDkey;
6756 arr[ukey_dl] = DLkey;
6757 arr[ukey_dr] = DRkey;
6758 arr[ukey_mod1a] = cheat_modifier_keys[0];
6759 arr[ukey_mod1b] = cheat_modifier_keys[1];
6760 arr[ukey_mod2a] = cheat_modifier_keys[2];
6761 arr[ukey_mod2b] = cheat_modifier_keys[3];
6762 };
6763
6764 static const char* ukey_names[] = {
6765 "A", "B", "Start", "L", "R", "Map",
6766 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6767 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6768 "Cheat Mod R1", "Cheat Mod R2",
6769 };
6770 std::string get_ukey_name(int32_t k)
6771 {
6772 if (k < num_ukey) return ukey_names[k];
6773 return "";
6774 }
6775
6776 int32_t onKeyboard()
6777 {
6778 int32_t a = Akey;
6779 int32_t b = Bkey;
6780 int32_t s = Skey;
6781 int32_t l = Lkey;
6782 int32_t r = Rkey;
6783 int32_t p = Pkey;
6784 int32_t ex1 = Exkey1;
6785 int32_t ex2 = Exkey2;
6786 int32_t ex3 = Exkey3;
6787 int32_t ex4 = Exkey4;
6788 int32_t du = DUkey;
6789 int32_t dd = DDkey;
6790 int32_t dl = DLkey;
6791 int32_t dr = DRkey;
6792 int32_t mod1a = cheat_modifier_keys[0];
6793 int32_t mod1b = cheat_modifier_keys[1];
6794 int32_t mod2a = cheat_modifier_keys[2];
6795 int32_t mod2b = cheat_modifier_keys[3];
6796 bool done=false;
6797 int32_t ret;
6798
6799 keyboard_control_dlg[0].dp2=lfont;
6800
6801 large_dialog(keyboard_control_dlg);
6802
6803 while(!done)
6804 {
6805 ret = zc_popup_dialog(keyboard_control_dlg,3);
6806
6807 if(ret==3) // OK
6808 {
6809 int32_t ukeys[num_ukey];
6810 load_ukeys(ukeys);
6811 std::vector<std::string> uniqueError;
6812 for(int32_t q = 0; q < num_ukey; ++q)
6813 {
6814 for(int32_t p = q+1; p < num_ukey; ++p)
6815 {
6816 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6817 {
6818 char buf[64];
6819 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6820 std::string str(buf);
6821 uniqueError.push_back(str);
6822 }
6823 }
6824 }
6825 if(uniqueError.size() == 0)
6826 {
6827 done = true;
6828 save_control_configs(true);
6829 }
6830 else
6831 {
6832 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6833 box_out("Cannot have duplicate keybinds!"); box_eol();
6834 for(std::vector<std::string>::iterator it = uniqueError.begin();
6835 it != uniqueError.end(); ++it)
6836 {
6837 box_out((*it).c_str()); box_eol();
6838 }
6839 box_end(true);
6840 }
6841 }
6842 else // Cancel
6843 {
6844 Akey = a;
6845 Bkey = b;
6846 Skey = s;
6847 Lkey = l;
6848 Rkey = r;
6849 Pkey = p;
6850 Exkey1 = ex1;
6851 Exkey2 = ex2;
6852 Exkey3 = ex3;
6853 Exkey4 = ex4;
6854 DUkey = du;
6855 DDkey = dd;
6856 DLkey = dl;
6857 DRkey = dr;
6858 cheat_modifier_keys[0] = mod1a;
6859 cheat_modifier_keys[1] = mod1b;
6860 cheat_modifier_keys[2] = mod2a;
6861 cheat_modifier_keys[3] = mod2b;
6862
6863 done=true;
6864 }
6865
6866 rest(1);
6867 }
6868
6869 return D_O_K;
6870 }
6871
6872 int32_t onGamepad()
6873 {
6874 int32_t a = Abtn;
6875 int32_t b = Bbtn;
6876 int32_t s = Sbtn;
6877 int32_t l = Lbtn;
6878 int32_t r = Rbtn;
6879 int32_t m = Mbtn;
6880 int32_t p = Pbtn;
6881 int32_t ex1 = Exbtn1;
6882 int32_t ex2 = Exbtn2;
6883 int32_t ex3 = Exbtn3;
6884 int32_t ex4 = Exbtn4;
6885 int32_t up = DUbtn;
6886 int32_t down = DDbtn;
6887 int32_t left = DLbtn;
6888 int32_t right = DRbtn;
6889
6890 gamepad_dlg[0].dp2=lfont;
6891 if(analog_movement)
6892 gamepad_dlg[56].flags|=D_SELECTED;
6893 else
6894 gamepad_dlg[56].flags&=~D_SELECTED;
6895
6896 large_dialog(gamepad_dlg);
6897
6898 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6899
6900 if(ret == 4) //OK
6901 {
6902 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6903 save_control_configs(false);
6904 }
6905 else //Cancel
6906 {
6907 Abtn = a;
6908 Bbtn = b;
6909 Sbtn = s;
6910 Lbtn = l;
6911 Rbtn = r;
6912 Mbtn = m;
6913 Pbtn = p;
6914 Exbtn1 = ex1;
6915 Exbtn2 = ex2;
6916 Exbtn3 = ex3;
6917 Exbtn4 = ex4;
6918 DUbtn = up;
6919 DDbtn = down;
6920 DLbtn = left;
6921 DRbtn = right;
6922 }
6923
6924 return D_O_K;
6925 }
6926
6927 int32_t onCheatKeys()
6928 {
6929 int32_t oldcheats[Cheat::Last][2];
6930 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6931
6932 bool done=false;
6933
6934 while(!done)
6935 {
6936 bool confirm = false;
6937 CheatKeysDialog(&confirm).show();
6938 if(confirm) // OK
6939 {
6940 std::vector<std::string> uniqueError;
6941 char buf[512];
6942 for(size_t q = 1; q < Cheat::Last; ++q)
6943 {
6944 if(cheatkeys[q][1] && !cheatkeys[q][0])
6945 {
6946 cheatkeys[q][0] = cheatkeys[q][1];
6947 cheatkeys[q][1] = 0;
6948 }
6949 }
6950 for(size_t q = 1; q < Cheat::Last; ++q)
6951 {
6952 if(!bindable_cheat((Cheat)q)) continue;
6953 for(size_t p = q+1; p < Cheat::Last; ++p)
6954 {
6955 if(!bindable_cheat((Cheat)p)) continue;
6956 for(size_t q2 = 0; q2 <= 1; ++q2)
6957 for(size_t p2 = 0; p2 <= 1; ++p2)
6958 {
6959 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6960 {
6961 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6962 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6963 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6964 get_keystr(cheatkeys[q][q2])));
6965 }
6966 }
6967 }
6968 }
6969 if(uniqueError.size() == 0)
6970 {
6971 done = true;
6972 save_cheatkeys();
6973 }
6974 else
6975 {
6976 box_start(1, "Duplicate Keys", lfont, sfont, false, 500,400, 2);
6977 box_out("Cannot have duplicate keybinds!"); box_eol();
6978 for(std::vector<std::string>::iterator it = uniqueError.begin();
6979 it != uniqueError.end(); ++it)
6980 {
6981 box_out((*it).c_str()); box_eol();
6982 }
6983 box_end(true);
6984 }
6985 }
6986 else // Cancel
6987 {
6988 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6989 done=true;
6990 }
6991 rest(1);
6992 }
6993
6994 return D_O_K;
6995 }
6996
6997 int32_t onSound()
6998 {
6999 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7000 {
7001 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7002 }
7003 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7004 {
7005 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7006 }
7007 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7008 {
7009 emusic_volume = (int32_t)FFCore.usr_music_volume;
7010 }
7011 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7012 {
7013 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7014 }
7015 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7016 {
7017 pan_style = (int32_t)FFCore.usr_panstyle;
7018 }
7019
7020 int32_t m = midi_volume;
7021 int32_t d = digi_volume;
7022 int32_t e = emusic_volume;
7023 int32_t b = zcmusic_bufsz;
7024 int32_t s = sfx_volume;
7025 int32_t p = pan_style;
7026 pan_style = vbound(pan_style,0,3);
7027
7028 sound_dlg[0].dp2=lfont;
7029
7030 large_dialog(sound_dlg);
7031
7032 midi_dp[1] = sound_dlg[6].x;
7033 midi_dp[2] = sound_dlg[6].y;
7034 digi_dp[1] = sound_dlg[7].x;
7035 digi_dp[2] = sound_dlg[7].y;
7036 emus_dp[1] = sound_dlg[8].x;
7037 emus_dp[2] = sound_dlg[8].y;
7038 buf_dp[1] = sound_dlg[9].x;
7039 buf_dp[2] = sound_dlg[9].y;
7040 sfx_dp[1] = sound_dlg[10].x;
7041 sfx_dp[2] = sound_dlg[10].y;
7042 pan_dp[1] = sound_dlg[11].x;
7043 pan_dp[2] = sound_dlg[11].y;
7044 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7045 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7046 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7047 sound_dlg[18].d2 = zcmusic_bufsz;
7048 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7049 sound_dlg[20].d2 = pan_style;
7050
7051 int32_t ret = zc_popup_dialog(sound_dlg,1);
7052
7053 if(ret==2)
7054 {
7055 master_volume(digi_volume,midi_volume);
7056
7057 for(int32_t i=0; i<WAV_COUNT; ++i)
7058 {
7059 //allegro assertion fails when passing in -1 as voice -DD
7060 if(sfx_voice[i] > 0)
7061 voice_set_volume(sfx_voice[i], sfx_volume);
7062 }
7063 zc_set_config(sfx_sect,"digi",digi_volume);
7064 zc_set_config(sfx_sect,"midi",midi_volume);
7065 zc_set_config(sfx_sect,"sfx",sfx_volume);
7066 zc_set_config(sfx_sect,"emusic",emusic_volume);
7067 zc_set_config(sfx_sect,"pan",pan_style);
7068 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7069 }
7070 else
7071 {
7072 midi_volume = m;
7073 digi_volume = d;
7074 emusic_volume = e;
7075 zcmusic_bufsz = b;
7076 sfx_volume = s;
7077 pan_style = p;
7078 }
7079
7080 return D_O_K;
7081 }
7082
7083 int32_t queding(char const* s1, char const* s2, char const* s3)
7084 {
7085 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7086 }
7087
7088 int32_t onQuit()
7089 {
7090 if(Playing)
7091 {
7092 int32_t ret=0;
7093
7094 if(get_bit(quest_rules, qr_NOCONTINUE))
7095 {
7096 if(standalone_mode)
7097 {
7098 ret=queding("End current game?",
7099 "The continue screen is disabled; the game",
7100 "will be reloaded from the last save.");
7101 }
7102 else
7103 {
7104 ret=queding("End current game?",
7105 "The continue screen is disabled. You will",
7106 "be returned to the file select screen.");
7107 }
7108 }
7109 else
7110 ret=queding("End current game?",NULL,NULL);
7111
7112 if(ret==1)
7113 {
7114 disableClickToFreeze=false;
7115 Quit=qQUIT;
7116
7117 // Trying to evade a door repair charge?
7118 if(repaircharge)
7119 {
7120 game->change_drupy(-repaircharge);
7121 repaircharge=0;
7122 }
7123
7124 return D_CLOSE;
7125 }
7126 }
7127
7128 return D_O_K;
7129 }
7130
7131 int32_t onTryQuitMenu()
7132 {
7133 return onTryQuit(true);
7134 }
7135
7136 int32_t onTryQuit(bool inMenu)
7137 {
7138 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7139 {
7140 if(get_bit(quest_rules,qr_OLD_F6))
7141 {
7142 if(inMenu) onQuit();
7143 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7144 }
7145 else
7146 {
7147 disableClickToFreeze=false;
7148 GameFlags |= GAMEFLAG_TRYQUIT;
7149 }
7150 return D_CLOSE;
7151 }
7152
7153 return D_O_K;
7154 }
7155
7156 int32_t onReset()
7157 {
7158 if(queding(" Reset system? ",NULL,NULL)==1)
7159 {
7160 disableClickToFreeze=false;
7161 Quit=qRESET;
7162 replay_quit();
7163 return D_CLOSE;
7164 }
7165
7166 return D_O_K;
7167 }
7168
7169 int32_t onExit()
7170 {
7171 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7172 {
7173 Quit=qEXIT;
7174 return D_CLOSE;
7175 }
7176
7177 return D_O_K;
7178 }
7179
7180 int32_t onTitle_NES()
7181 {
7182 title_version=0;
7183 zc_set_config(cfg_sect,"title",title_version);
7184 return D_O_K;
7185 }
7186 int32_t onTitle_DX()
7187 {
7188 title_version=1;
7189 zc_set_config(cfg_sect,"title",title_version);
7190 return D_O_K;
7191 }
7192 int32_t onTitle_25()
7193 {
7194 title_version=2;
7195 zc_set_config(cfg_sect,"title",title_version);
7196 return D_O_K;
7197 }
7198
7199 int32_t onDebug()
7200 {
7201 if(debug_enabled)
7202 set_debug(!get_debug());
7203 return D_O_K;
7204 }
7205
7206 int32_t onHeartBeep()
7207 {
7208 heart_beep=!heart_beep;
7209 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7210 return D_O_K;
7211 }
7212
7213 int32_t onSaveIndicator()
7214 {
7215 use_save_indicator=!use_save_indicator;
7216 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7217 return D_O_K;
7218 }
7219
7220 int32_t onEpilepsy()
7221 {
7222 if(jwin_alert3(
7223 "Epilepsy Flash Reduction",
7224 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7225 "Disabling this will restore standard flash and wavy behaviour.",
7226 "Proceed?",
7227 "&Yes",
7228 "&No",
7229 NULL,
7230 'y',
7231 'n',
7232 0,
7233 lfont) == 1)
7234 {
7235 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7236 zc_set_config("zeldadx","checked_epilepsy",1);
7237 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7238 }
7239 return D_O_K;
7240 }
7241
7242 int32_t onTriforce()
7243 {
7244 for(int32_t i=0; i<MAXINITTABS; ++i)
7245 {
7246 init_tabs[i].flags&=~D_SELECTED;
7247 }
7248
7249 init_tabs[3].flags=D_SELECTED;
7250 return onCheatConsole();
7251 /*triforce_dlg[0].dp2=lfont;
7252 for(int32_t i=1; i<=8; i++)
7253 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7254
7255 if(zc_popup_dialog (triforce_dlg,-1)==9)
7256 {
7257 for(int32_t i=1; i<=8; i++)
7258 {
7259 game->lvlitems[i] &= ~liTRIFORCE;
7260 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7261 }
7262 }
7263 return D_O_K;*/
7264 }
7265
7266 bool rc = false;
7267 /*
7268 int32_t onEquipment()
7269 {
7270 for (int32_t i=0; i<MAXINITTABS; ++i)
7271 {
7272 init_tabs[i].flags&=~D_SELECTED;
7273 }
7274 init_tabs[0].flags=D_SELECTED;
7275 return onCheatConsole();
7276 }
7277 */
7278
7279 int32_t onItems()
7280 {
7281 for(int32_t i=0; i<MAXINITTABS; ++i)
7282 {
7283 init_tabs[i].flags&=~D_SELECTED;
7284 }
7285
7286 init_tabs[1].flags=D_SELECTED;
7287 return onCheatConsole();
7288 }
7289
7290 static DIALOG getnum_dlg[] =
7291 {
7292 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7293 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7294 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7295 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7296 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7297 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7298 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7299 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7300 };
7301
7302 int32_t getnumber(const char *prompt,int32_t initialval)
7303 {
7304 char buf[20];
7305 sprintf(buf,"%d",initialval);
7306 getnum_dlg[0].dp=(void *)prompt;
7307 getnum_dlg[0].dp2=lfont;
7308 getnum_dlg[2].dp=buf;
7309
7310 large_dialog(getnum_dlg);
7311
7312 if(zc_popup_dialog(getnum_dlg,2)==3)
7313 return atoi(buf);
7314
7315 return initialval;
7316 }
7317
7318 int32_t onLife()
7319 {
7320 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7321 cheats_enqueue(Cheat::Life, value);
7322 return D_O_K;
7323 }
7324
7325 int32_t onHeartC()
7326 {
7327 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7328 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7329 cheats_enqueue(Cheat::MaxLife, max_life);
7330 cheats_enqueue(Cheat::Life, life);
7331 return D_O_K;
7332 }
7333
7334 int32_t onMagicC()
7335 {
7336 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7337 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7338 cheats_enqueue(Cheat::MaxMagic, max_magic);
7339 cheats_enqueue(Cheat::Magic, magic);
7340 return D_O_K;
7341 }
7342
7343 int32_t onRupies()
7344 {
7345 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7346 cheats_enqueue(Cheat::Rupies, value);
7347 return D_O_K;
7348 }
7349
7350 int32_t onMaxBombs()
7351 {
7352 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7353 cheats_enqueue(Cheat::MaxBombs, value);
7354 cheats_enqueue(Cheat::Bombs, value);
7355 return D_O_K;
7356 }
7357
7358 int32_t onRefillLife()
7359 {
7360 cheats_enqueue(Cheat::Life, game->get_maxlife());
7361 return D_O_K;
7362 }
7363 int32_t onRefillMagic()
7364 {
7365 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7366 return D_O_K;
7367 }
7368 int32_t onClock()
7369 {
7370 cheats_enqueue(Cheat::Clock);
7371 return D_O_K;
7372 }
7373
7374 int32_t onQstPath()
7375 {
7376 char path[2048];
7377
7378 chop_path(qstdir);
7379 strcpy(path,qstdir);
7380
7381 go();
7382
7383 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7384 {
7385 chop_path(path);
7386 fix_filename_case(path);
7387 fix_filename_slashes(path);
7388 strcpy(qstdir,path);
7389 strcpy(qstpath,qstdir);
7390 }
7391
7392 comeback();
7393 return D_O_K;
7394 }
7395
7396 #include "dialog/cheat_dialog.h"
7397 int32_t onCheat()
7398 {
7399 call_setcheat_dialog();
7400 game->set_cheat(maxcheat);
7401 if(cheat) game->did_cheat(true);
7402 return D_O_K;
7403 }
7404
7405 int32_t onCheatRupies()
7406 {
7407 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7408 return D_O_K;
7409 }
7410
7411 int32_t onCheatArrows()
7412 {
7413 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7414 return D_O_K;
7415 }
7416
7417 int32_t onCheatBombs()
7418 {
7419 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7420 return D_O_K;
7421 }
7422
7423 // *** screen saver
7424
7425 6510614 int32_t after_time()
7426 {
7427
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(ss_enable == 0)
7428 return INT_MAX;
7429
7430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 0)
7431 return 5 * 60;
7432
7433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 3)
7434 return ss_after * 15 * 60;
7435
7436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 13)
7437 return (ss_after - 3) * 60 * 60;
7438
7439 6510614 return MAX_IDLE + 1;
7440 6510614 }
7441
7442 static const char *after_str[15] =
7443 {
7444 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7445 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7446 "Never"
7447 };
7448
7449 const char *after_list(int32_t index, int32_t *list_size)
7450 {
7451 if(index < 0)
7452 {
7453 *list_size = 15;
7454 return NULL;
7455 }
7456
7457 return after_str[index];
7458 }
7459
7460 29 static ListData after__list(after_list, &font);
7461
7462 static DIALOG scrsaver_dlg[] =
7463 {
7464 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7465 29 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7466 29 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7467 29 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7468 29 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7469 29 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7470 29 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7471 29 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7472 29 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7473 29 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7474 29 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7475 29 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7476 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7477 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7478 };
7479
7480 int32_t onScreenSaver()
7481 {
7482 scrsaver_dlg[0].dp2=lfont;
7483 int32_t oldcfgs[3];
7484 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7485 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7486 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7487
7488 large_dialog(scrsaver_dlg);
7489
7490 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7491
7492 if(ret == 8 || ret == 9)
7493 {
7494 ss_after = scrsaver_dlg[5].d1;
7495 ss_speed = scrsaver_dlg[6].d2;
7496 ss_density = scrsaver_dlg[7].d2;
7497 if(oldcfgs[0] != ss_after)
7498 zc_set_config(cfg_sect,"ss_after",ss_after);
7499 if(oldcfgs[1] != ss_speed)
7500 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7501 if(oldcfgs[2] != ss_density)
7502 zc_set_config(cfg_sect,"ss_density",ss_density);
7503 }
7504
7505 if(ret == 9)
7506 // preview Screen Saver
7507 {
7508 clear_keybuf();
7509 scare_mouse();
7510 Matrix(ss_speed, ss_density, 30);
7511 system_pal();
7512 unscare_mouse();
7513 }
7514
7515 return D_O_K;
7516 }
7517
7518 /***** Menus *****/
7519
7520 static MENU game_menu[] =
7521 {
7522 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7523 { (char *)"", NULL, NULL, 0, NULL },
7524 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7525 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7526 { (char *)"", NULL, NULL, 0, NULL },
7527 #ifdef __EMSCRIPTEN__
7528 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7529 #elif defined(ALLEGRO_MACOSX)
7530 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7531 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7532 #else
7533 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7534 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7535 #endif
7536 { NULL, NULL, NULL, 0, NULL }
7537 };
7538
7539 static MENU title_menu[] =
7540 {
7541 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7542 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7543 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7544 { NULL, NULL, NULL, 0, NULL }
7545 };
7546
7547 static MENU snapshot_format_menu[] =
7548 {
7549 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7550 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7551 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7552 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7553 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7554 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7555 { NULL, NULL, NULL, 0, NULL }
7556 };
7557
7558 static MENU controls_menu[] =
7559 {
7560 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7561 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7562 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7563 { NULL, NULL, NULL, 0, NULL }
7564 };
7565
7566 static MENU name_entry_mode_menu[] =
7567 {
7568 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7569 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7570 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7571 { NULL, NULL, NULL, 0, NULL }
7572 };
7573
7574 static void set_controls_menu_active()
7575 {
7576
7577 }
7578
7579 static MENU window_menu[] =
7580 {
7581 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7582 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7583 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7584 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7585 { NULL, NULL, NULL, 0, NULL }
7586 };
7587 static MENU options_menu[] =
7588 {
7589 { "&Title Screen", NULL, title_menu, 0, NULL },
7590 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7591 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7592 { "&Window Settings", NULL, window_menu, 0, NULL },
7593 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7594 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7595 { NULL, NULL, NULL, 0, NULL }
7596 };
7597 static MENU settings_menu[] =
7598 {
7599 { "&Sound...", onSound, NULL, 0, NULL },
7600 { "C&ontrols", NULL, controls_menu, 0, NULL },
7601 { "", NULL, NULL, 0, NULL },
7602 { "Options", NULL, options_menu, 0, NULL },
7603 { "", NULL, NULL, 0, NULL },
7604 //
7605 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7606 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7607 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7608 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7609 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7610 //
7611 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7612 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7613 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7614 { "", NULL, NULL, 0, NULL },
7615 { "Debu&g", onDebug, NULL, 0, NULL },
7616 //
7617 { NULL, NULL, NULL, 0, NULL }
7618 };
7619
7620
7621 static MENU misc_menu[] =
7622 {
7623 { (char *)"&About...", onAbout, NULL, 0, NULL },
7624 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7625 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7626 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7627 { (char *)"", NULL, NULL, 0, NULL },
7628 //5
7629 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7630 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7631 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7632 { (char *)"", NULL, NULL, 0, NULL },
7633 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7634 //10
7635 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7636 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7637 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7638 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7639 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7640 //15
7641 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7642 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7643 { NULL, NULL, NULL, 0, NULL }
7644 };
7645
7646 static MENU refill_menu[] =
7647 {
7648 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7649 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7650 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7651 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7652 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7653 { NULL, NULL, NULL, 0, NULL }
7654 };
7655
7656 static MENU show_menu[] =
7657 {
7658 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7659 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7660 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7661 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7662 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7663 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7664 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7665 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7666 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7667 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7668 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7669 { (char *)"", NULL, NULL, 0, NULL },
7670 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7671 { (char *)"", NULL, NULL, 0, NULL },
7672 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7673 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7674 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7675 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7676 { NULL, NULL, NULL, 0, NULL }
7677 };
7678
7679 static MENU cheat_menu[] =
7680 {
7681 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7682 { (char *)"", NULL, NULL, 0, NULL },
7683 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7684 { (char *)"", NULL, NULL, 0, NULL },
7685 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7686 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7687 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7688 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7689 { (char *)"", NULL, NULL, 0, NULL },
7690 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7691 { (char *)"", NULL, NULL, 0, NULL },
7692 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7693 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7694 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7695 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7696 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7697 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7698 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7699 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7700 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7701 { NULL, NULL, NULL, 0, NULL }
7702 };
7703
7704 #if DEVLEVEL > 0
7705 int32_t devLogging();
7706 int32_t devDebug();
7707 int32_t devTimestmp();
7708 #if DEVLEVEL > 1
7709 int32_t setCheat();
7710 #endif //DEVLEVEL > 1
7711 enum
7712 {
7713 dv_log,
7714 // dv_dbg,
7715 dv_tmpstmp,
7716 #if DEVLEVEL > 1
7717 dv_nil,
7718 dv_setcheat,
7719 #endif //DEVLEVEL > 1
7720 dv_max
7721 };
7722 static MENU dev_menu[] =
7723 {
7724 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7725 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7726 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7727 #if DEVLEVEL > 1
7728 { (char *)"", NULL, NULL, 0, NULL },
7729 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7730 #endif //DEVLEVEL > 1
7731 { NULL, NULL, NULL, 0, NULL }
7732 };
7733 int32_t devLogging()
7734 {
7735 dev_logging = !dev_logging;
7736 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7737 return D_O_K;
7738 }
7739 // int32_t devDebug()
7740 // {
7741 // dev_debug = !dev_debug;
7742 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7743 // return D_O_K;
7744 // }
7745 int32_t devTimestmp()
7746 {
7747 dev_timestmp = !dev_timestmp;
7748 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7749 return D_O_K;
7750 }
7751 #if DEVLEVEL > 1
7752 int32_t setCheat()
7753 {
7754 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7755 return D_O_K;
7756 }
7757 #endif //DEVLEVEL > 1
7758 #endif //DEVLEVEL > 0
7759
7760 MENU the_player_menu[] =
7761 {
7762 { (char *)"&Game", NULL, game_menu, 0, NULL },
7763 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7764 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7765 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7766 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7767 #if DEVLEVEL > 0
7768 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7769 #endif
7770 { NULL, NULL, NULL, 0, NULL }
7771 };
7772 int32_t onMIDIPatch()
7773 {
7774 if(jwin_alert3(
7775 "Toggle Windows MIDI Fix",
7776 "This action will change whether ZC Player auto-restarts a MIDI at its",
7777 "last index if you move ZC Player out of focus, then back into focus.",
7778 "Proceed?",
7779 "&Yes",
7780 "&No",
7781 NULL,
7782 'y',
7783 'n',
7784 0,
7785 lfont) == 1)
7786 {
7787 midi_patch_fix = midi_patch_fix ? 0 : 1;
7788 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7789 }
7790 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7791 return D_O_K;
7792 }
7793
7794 int32_t onKeyboardEntry()
7795 {
7796 NameEntryMode=0;
7797 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7798 return D_O_K;
7799 }
7800
7801 int32_t onLetterGridEntry()
7802 {
7803 NameEntryMode=1;
7804 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7805 return D_O_K;
7806 }
7807
7808 int32_t onExtLetterGridEntry()
7809 {
7810 NameEntryMode=2;
7811 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7812 return D_O_K;
7813 }
7814
7815 static BITMAP* oldscreen;
7816 int32_t onFullscreenMenu()
7817 {
7818 // super hacks
7819 screen = oldscreen;
7820 if (onFullscreen() == D_REDRAW)
7821 {
7822 oldscreen = screen;
7823 }
7824 screen = menu_bmp;
7825 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7826 return D_O_K;
7827 }
7828
7829 29 void fix_menu()
7830 {
7831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!debug_enabled)
7832 29 settings_menu[13].text = NULL;
7833 29 }
7834
7835 static DIALOG system_dlg[] =
7836 {
7837 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7838 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7839 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7840 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7841 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7842 #ifndef ALLEGRO_MACOSX
7843 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7844 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7845 #else
7846 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7847 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7848 #endif
7849 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7850 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7851 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7852 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7853 };
7854
7855 void reset_snapshot_format_menu()
7856 {
7857 for(int32_t i=0; i<ssfmtMAX; ++i)
7858 {
7859 snapshot_format_menu[i].flags=0;
7860 }
7861 }
7862
7863 int32_t onSetSnapshotFormat()
7864 {
7865 switch(active_menu->text[1])
7866 {
7867 case 'B': //"&BMP"
7868 SnapshotFormat=0;
7869 break;
7870
7871 case 'G': //"&GIF"
7872 SnapshotFormat=1;
7873 break;
7874
7875 case 'J': //"&JPG"
7876 SnapshotFormat=2;
7877 break;
7878
7879 case 'P': //"&PNG"
7880 SnapshotFormat=3;
7881 break;
7882
7883 case 'C': //"PC&X"
7884 SnapshotFormat=4;
7885 break;
7886
7887 case 'T': //"&TGA"
7888 SnapshotFormat=5;
7889 break;
7890
7891 case 'L': //"&LBM"
7892 SnapshotFormat=6;
7893 break;
7894 }
7895 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7896
7897 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7898 return D_O_K;
7899 }
7900
7901
7902 43 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7903 {
7904 PALETTE tmp;
7905
7906
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 43 times.
11051 for(int32_t i=0; i<256; i++)
7907 {
7908 11008 tmp[i].r=r;
7909 11008 tmp[i].g=g;
7910 11008 tmp[i].b=b;
7911 11008 }
7912
7913 43 fade_interpolate(src,tmp,dest,pos,from,to);
7914 43 }
7915
7916 43 void system_pal()
7917 {
7918 43 is_sys_pal = true;
7919 static PALETTE pal;
7920 43 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7921
7922 // set up the grayscale palette
7923
2/2
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 43 times.
2795 for(int32_t i=128; i<192; i++)
7924 {
7925 2752 pal[i].r = i-128;
7926 2752 pal[i].g = i-128;
7927 2752 pal[i].b = i-128;
7928 2752 }
7929 43 load_colorset(gui_colorset, pal, jwin_a5_colors);
7930
7931 43 color_layer(pal, pal, 24,16,16, 28, 128,191);
7932
7933
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 43 times.
5547 for(int32_t i=0; i<256; i+=2)
7934 {
7935 5504 int32_t v = (i>>3)+2;
7936 5504 int32_t c = (i>>3)+192;
7937 5504 pal[c] = _RGB(v,v,v+(v>>1));
7938 /*
7939 if(i<240)
7940 {
7941 _allegro_hline(tmp_scr,0,i,319,c);
7942 _allegro_hline(tmp_scr,0,i+1,319,c);
7943 }
7944 */
7945 5504 }
7946
7947 // draw the vertical screen gradient
7948
2/2
✓ Branch 0 taken 10320 times.
✓ Branch 1 taken 43 times.
10363 for(int32_t i=0; i<240; ++i)
7949 {
7950 10320 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7951 10320 }
7952
7953 /*
7954 palrstart= 10*63/255; palrend=166*63/255;
7955 palgstart= 36*63/255; palgend=202*63/255;
7956 palbstart=106*63/255; palbend=240*63/255;
7957 paldivs=32;
7958 for(int32_t i=0; i<paldivs; i++)
7959 {
7960 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7961 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7962 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7963 }
7964 */
7965 43 BITMAP *panorama = create_bitmap_ex(8,256,224);
7966 int32_t ts_height, ts_start;
7967
7968
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7969 {
7970 clear_to_color(panorama,0);
7971 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7972 ts_height=224-passive_subscreen_height;
7973 ts_start=28;
7974 }
7975 else
7976 {
7977 43 blit(framebuf,panorama,0,0,0,0,256,224);
7978 43 ts_height=224;
7979 43 ts_start=0;
7980 }
7981
7982 // gray scale the current frame
7983
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 43 times.
9675 for(int32_t y=0; y<ts_height; y++)
7984 {
7985
2/2
✓ Branch 0 taken 2465792 times.
✓ Branch 1 taken 9632 times.
2475424 for(int32_t x=0; x<256; x++)
7986 {
7987 2465792 int32_t c = panorama->line[y+ts_start][x];
7988
2/2
✓ Branch 0 taken 2459902 times.
✓ Branch 1 taken 5890 times.
2465792 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
7989 2465792 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
7990 2465792 }
7991 9632 }
7992
7993 43 destroy_bitmap(panorama);
7994
7995 // display everything
7996 43 vsync();
7997 43 hw_palette = &pal;
7998 43 update_hw_pal = true;
7999
8000 // sys_pal = pal;
8001 43 memcpy(sys_pal,pal,sizeof(pal));
8002 43 }
8003
8004 void system_pal2()
8005 {
8006 is_sys_pal = true;
8007 static PALETTE RAMpal2;
8008 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8009
8010 /* Windows 2000 colors
8011 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8012 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8013 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8014 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8015 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8016 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8017 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8018 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8019
8020 byte palrstart= 10*63/255, palrend=166*63/255,
8021 palgstart= 36*63/255, palgend=202*63/255,
8022 palbstart=106*63/255, palbend=240*63/255,
8023 paldivs=7;
8024 for(int32_t i=0; i<paldivs; i++)
8025 {
8026 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8027 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8028 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8029 }
8030 */
8031
8032 /* Windows 98 colors
8033 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8034 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8035 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8036 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8037 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8038 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8039 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8040 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8041
8042 byte palrstart= 0*63/255, palrend=166*63/255,
8043 palgstart= 0*63/255, palgend=202*63/255,
8044 palbstart=128*63/255, palbend=240*63/255,
8045 paldivs=7;
8046 for(int32_t i=0; i<paldivs; i++)
8047 {
8048 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8049 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8050 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8051 }
8052 */
8053
8054 /* Windows 99 colors
8055 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8056 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8057 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8058 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8059 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8060 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8061 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8062 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8063 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8064
8065 byte palrstart= 0*63/255, palrend=166*63/255,
8066 palgstart= 0*63/255, palgend=202*63/255,
8067
8068 palbstart=128*63/255, palbend=240*63/255,
8069 paldivs=6;
8070 for(int32_t i=0; i<paldivs; i++)
8071 {
8072 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8073 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8074 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8075 }
8076 */
8077
8078
8079
8080 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8081 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8082 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8083 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8084 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8085 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8086 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8087 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8088 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8089
8090 byte palrstart= 0*63/255, palrend=166*63/255,
8091 palgstart= 0*63/255, palgend=202*63/255,
8092 palbstart=128*63/255, palbend=240*63/255,
8093 paldivs=6;
8094
8095 for(int32_t i=0; i<paldivs; i++)
8096 {
8097 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8098 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8099 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8100 }
8101
8102 gui_bg_color=jwin_pal[jcBOX];
8103 gui_fg_color=jwin_pal[jcBOXFG];
8104
8105 jwin_set_colors(jwin_pal);
8106
8107
8108 // set up the new palette
8109 for(int32_t i=128; i<192; i++)
8110 {
8111 RAMpal2[i].r = i-128;
8112 RAMpal2[i].g = i-128;
8113 RAMpal2[i].b = i-128;
8114 }
8115
8116 /*
8117 for(int32_t i=0; i<64; i++)
8118 {
8119 RAMpal2[128+i] = _RGB(i,i,i)1));
8120 }
8121 */
8122
8123 /*
8124
8125 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8126 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8127 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8128 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8129 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8130 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8131 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8132
8133 gui_fg_color=vc(14);
8134 gui_bg_color=vc(1);
8135
8136 jwin_set_colors(jwin_pal);
8137 */
8138
8139 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8140
8141 // set up the colors for the vertical screen gradient
8142 for(int32_t i=0; i<256; i+=2)
8143 {
8144 int32_t v = (i>>3)+2;
8145 int32_t c = (i>>3)+192;
8146 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8147
8148 /*
8149 if(i<240)
8150 {
8151 _allegro_hline(tmp_scr,0,i,319,c);
8152 _allegro_hline(tmp_scr,0,i+1,319,c);
8153 }
8154 */
8155 }
8156
8157 // hw_palette = &RAMpal;
8158 // update_hw_pal = true;
8159
8160 for(int32_t i=0; i<240; ++i)
8161 {
8162 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8163 }
8164
8165 /*
8166 byte palrstart= 10*63/255, palrend=166*63/255,
8167 palgstart= 36*63/255, palgend=202*63/255,
8168 palbstart=106*63/255, palbend=240*63/255,
8169 paldivs=32;
8170 for(int32_t i=0; i<paldivs; i++)
8171 {
8172 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8173 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8174 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8175 }
8176 */
8177 BITMAP *panorama = create_bitmap_ex(8,256,224);
8178 int32_t ts_height, ts_start;
8179
8180 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8181 {
8182 clear_to_color(panorama,0);
8183 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8184 ts_height=224-passive_subscreen_height;
8185 ts_start=28;
8186 }
8187 else
8188 {
8189 blit(framebuf,panorama,0,0,0,0,256,224);
8190 ts_height=224;
8191 ts_start=0;
8192 }
8193
8194 // gray scale the current frame
8195 for(int32_t y=0; y<ts_height; y++)
8196 {
8197 for(int32_t x=0; x<256; x++)
8198 {
8199 int32_t c = panorama->line[y+ts_start][x];
8200 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8201 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8202 }
8203 }
8204
8205 destroy_bitmap(panorama);
8206
8207 // display everything
8208 vsync();
8209 hw_palette = &RAMpal2;
8210 update_hw_pal = true;
8211
8212 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8213
8214 // sys_pal = pal;
8215 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8216 }
8217
8218 static uint32_t entered_sys_pal = 0;
8219 14 void enter_sys_pal()
8220 {
8221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8222 {
8223 if(entered_sys_pal)
8224 ++entered_sys_pal;
8225 return;
8226 }
8227 14 system_pal();
8228 14 ++entered_sys_pal;
8229 14 }
8230 14 void exit_sys_pal()
8231 {
8232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8233 {
8234
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8235 {
8236 14 game_pal();
8237 14 }
8238 14 }
8239 14 }
8240
8241 void switch_out_callback()
8242 {
8243 if (pause_in_background)
8244 {
8245 callback_switchin = 3;
8246 return;
8247 }
8248
8249 #ifdef _WIN32
8250 if(midi_patch_fix==0 || currmidi==-1)
8251 return;
8252
8253
8254 paused_midi_pos = midi_pos;
8255 zc_stop_midi();
8256 midi_paused=true;
8257 midi_suspended = midissuspHALTED;
8258 #endif
8259 }
8260
8261 void switch_in_callback()
8262 {
8263 if(pause_in_background)
8264 {
8265 return;
8266 }
8267
8268 #ifdef _WIN32
8269 if(midi_patch_fix==0 || currmidi==-1)
8270 return;
8271
8272 else
8273 {
8274 callback_switchin = 1;
8275 midi_suspended = midissuspRESUME;
8276 }
8277 #endif
8278 }
8279
8280 257 void game_pal()
8281 {
8282 257 is_sys_pal = false;
8283 257 entered_sys_pal = 0;
8284 257 clear_to_color(screen,BLACK);
8285 257 hw_palette = &RAMpal;
8286 257 update_hw_pal = true;
8287 257 }
8288
8289 static char bar_str[] = "";
8290
8291 14 void music_pause()
8292 {
8293 //al_pause_duh(tmplayer);
8294 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8295 14 zc_midi_pause();
8296 14 midi_paused=true;
8297 14 }
8298
8299 void music_resume()
8300 {
8301 //al_resume_duh(tmplayer);
8302 zcmusic_pause(zcmusic, ZCM_RESUME);
8303 zc_midi_resume();
8304 midi_paused=false;
8305 }
8306
8307 5320 void music_stop()
8308 {
8309 //al_stop_duh(tmplayer);
8310 //unload_duh(tmusic);
8311 //tmusic=NULL;
8312 //tmplayer=NULL;
8313 5320 zcmusic_stop(zcmusic);
8314 5320 zcmusic_unload_file(zcmusic);
8315 5320 zc_stop_midi();
8316 5320 midi_paused=false;
8317 5320 currmidi=-1;
8318 5320 }
8319
8320 void System()
8321 {
8322 mouse_down=gui_mouse_b();
8323 music_pause();
8324 pause_all_sfx();
8325 MenuOpen = true;
8326 system_pal();
8327 // FONT *oldfont=font;
8328 // font=tfont;
8329
8330 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8331 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8332
8333 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8334 #if DEVLEVEL > 1
8335 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8336 #endif
8337 game_menu[3].flags =
8338 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8339 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8340 clear_keybuf();
8341 show_mouse(screen);
8342
8343 DIALOG_PLAYER *p;
8344
8345 clear_bitmap(menu_bmp);
8346 oldscreen = screen;
8347 screen = menu_bmp;
8348
8349 p = init_dialog(system_dlg,-1);
8350
8351 // drop the menu on startup if menu button pressed
8352 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8353 simulate_keypress(KEY_G << 8);
8354
8355 do
8356 {
8357 if(close_button_quit)
8358 {
8359 close_button_quit = false;
8360 f_Quit(qEXIT);
8361 if(Quit) break;
8362 }
8363 rest(17);
8364
8365 if(mouse_down && !gui_mouse_b())
8366 mouse_down=0;
8367
8368 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8369 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8370 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8371
8372 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8373 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8374 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8375 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8376 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8377 settings_menu[10].flags = NESquit?D_SELECTED:0;
8378 settings_menu[11].flags = volkeys?D_SELECTED:0;
8379
8380 window_menu[0].flags = DragAspect?D_SELECTED:0;
8381 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8382 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8383 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8384
8385 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8386 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8387
8388 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8389 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8390 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8391
8392 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8393 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8394 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8395 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8396
8397 bool nocheat = (replay_is_replaying() || !Playing
8398 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8399 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8400 cheat_menu[0].flags = 0;
8401 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8402 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8403 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8404 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8405 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8406 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8407 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8408 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8409 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8410
8411 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8412 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8413 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8414 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8415 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8416 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8417 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8418 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8419 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8420 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8421 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8422 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8423 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8424 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8425 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8426
8427 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8428 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8429
8430 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8431 (char *)"Disable recording new saves" :
8432 (char *)"Enable recording new saves";
8433 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8434 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8435 (char *)"Stop recording" :
8436 (char *)"Stop replaying";
8437 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8438 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8439 (char *)"Disable snapshot all frames" :
8440 (char *)"Enable snapshot all frames";
8441
8442 reset_snapshot_format_menu();
8443 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8444
8445 if(debug_enabled)
8446 {
8447 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8448 }
8449
8450 if(gui_mouse_b() && !mouse_down)
8451 break;
8452
8453 // press menu to drop the menu
8454 if(rMbtn())
8455 simulate_keypress(KEY_G << 8);
8456
8457 if(input_idle(true) > after_time())
8458 // run Screeen Saver
8459 {
8460 // Screen saver enabled for now.
8461 clear_keybuf();
8462 scare_mouse();
8463 Matrix(ss_speed, ss_density, 0);
8464 system_pal();
8465 unscare_mouse();
8466 broadcast_dialog_message(MSG_DRAW, 0);
8467 }
8468
8469 update_hw_screen();
8470 }
8471 while(update_dialog(p));
8472
8473 screen = oldscreen;
8474
8475 // font=oldfont;
8476 mouse_down=gui_mouse_b();
8477 shutdown_dialog(p);
8478 show_mouse(NULL);
8479 MenuOpen = false;
8480 if(Quit)
8481 {
8482 kill_sfx();
8483 music_stop();
8484 update_hw_screen();
8485 }
8486 else
8487 {
8488 game_pal();
8489 music_resume();
8490 resume_all_sfx();
8491
8492 if(rc)
8493 ringcolor(false);
8494 }
8495
8496 eat_buttons();
8497
8498 rc=false;
8499 clear_keybuf();
8500 // text_mode(0);
8501 }
8502
8503 29 void fix_dialogs()
8504 {
8505 29 jwin_center_dialog(about_dlg);
8506 29 jwin_center_dialog(gamepad_dlg);
8507 29 jwin_center_dialog(credits_dlg);
8508 29 jwin_center_dialog(gamemode_dlg);
8509 29 jwin_center_dialog(getnum_dlg);
8510 29 jwin_center_dialog(goto_dlg);
8511 29 jwin_center_dialog(keyboard_control_dlg);
8512 29 jwin_center_dialog(midi_dlg);
8513 29 jwin_center_dialog(quest_dlg);
8514 29 jwin_center_dialog(scrsaver_dlg);
8515 29 jwin_center_dialog(sound_dlg);
8516 29 jwin_center_dialog(triforce_dlg);
8517
8518 // digi_dp[1] += scrx;
8519 // digi_dp[2] += scry;
8520 // midi_dp[1] += scrx;
8521 // midi_dp[2] += scry;
8522 // pan_dp[1] += scrx;
8523 // pan_dp[2] += scry;
8524 // emus_dp[1] += scrx;
8525 // emus_dp[2] += scry;
8526 // buf_dp[1] += scrx;
8527 // buf_dp[2] += scry;
8528 // sfx_dp[1] += scrx;
8529 // sfx_dp[2] += scry;
8530 29 }
8531
8532 /*****************************/
8533 /**** Custom Sound System ****/
8534 /*****************************/
8535
8536 2295 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8537 {
8538
3/4
✓ Branch 0 taken 2061 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 2295 times.
✗ Branch 3 not taken.
2295 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8539 }
8540
8541 // Run an NSF, or a MIDI if the NSF is missing somehow.
8542 83 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8543 {
8544 83 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8545
8546 // Found it
8547
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 35 times.
83 if(newzcmusic!=NULL)
8548 {
8549 48 zcmusic_stop(zcmusic);
8550 48 zcmusic_unload_file(zcmusic);
8551 48 zc_stop_midi();
8552
8553 48 zcmusic=newzcmusic;
8554 48 zcmusic_play(zcmusic, emusic_volume);
8555
8556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(track>0)
8557 48 zcmusic_change_track(zcmusic,track);
8558
8559 48 return true;
8560 }
8561
8562 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8563
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8564 jukebox(midi);
8565
8566 35 return false;
8567 83 }
8568
8569 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8570 {
8571 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8572 // Found it
8573 if(newzcmusic!=NULL)
8574 {
8575 zcmusic_stop(zcmusic);
8576 zcmusic_unload_file(zcmusic);
8577 zc_stop_midi();
8578
8579 zcmusic=newzcmusic;
8580 zcmusic_play(zcmusic, emusic_volume);
8581
8582 if(track>0)
8583 zcmusic_change_track(zcmusic,track);
8584
8585 return true;
8586 }
8587
8588 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8589 else if(midi>-1000)
8590 jukebox(midi);
8591
8592 return false;
8593 }
8594
8595 int32_t get_zcmusicpos()
8596 {
8597 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8598 return debugtracething;
8599 return 0;
8600 }
8601
8602 void set_zcmusicpos(int32_t position)
8603 {
8604 zcmusic_set_curpos(zcmusic, position);
8605 }
8606
8607 void set_zcmusicspeed(int32_t speed)
8608 {
8609 int32_t newspeed = vbound(speed, 0, 10000);
8610 zcmusic_set_speed(zcmusic, newspeed);
8611 }
8612
8613 1133 void jukebox(int32_t index,int32_t loop)
8614 {
8615 1133 music_stop();
8616
8617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(index<0) index=MAXMIDIS-1;
8618
8619
1/2
✓ Branch 0 taken 1133 times.
✗ Branch 1 not taken.
1133 if(index>=MAXMIDIS) index=0;
8620
8621 1133 music_stop();
8622
8623 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8624 // stuck notes when a song stops. This fixes it.
8625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(strcmp(midi_driver->name, "DIGMID")==0)
8626 zc_set_volume(0, 0);
8627
8628 1133 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8629 1133 zc_play_midi((MIDI*)tunes[index].data,loop);
8630
8631
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 377 times.
1133 if(tunes[index].start>0)
8632 377 zc_midi_seek(tunes[index].start);
8633
8634 1133 midi_loop_start = tunes[index].loop_start;
8635 1133 midi_loop_end = tunes[index].loop_end;
8636
8637 1133 currmidi=index;
8638 1133 master_volume(digi_volume,midi_volume);
8639 1133 midi_paused=false;
8640 1133 }
8641
8642 8589 void jukebox(int32_t index)
8643 {
8644
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index<0) index=MAXMIDIS-1;
8645
8646
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index>=MAXMIDIS) index=0;
8647
8648 // do nothing if it's already playing
8649
3/4
✓ Branch 0 taken 7456 times.
✓ Branch 1 taken 1133 times.
✓ Branch 2 taken 7456 times.
✗ Branch 3 not taken.
8589 if(index==currmidi && midi_pos>=0)
8650 {
8651 7456 midi_paused=false;
8652 7456 return;
8653 }
8654
8655 1133 jukebox(index,tunes[index].loop);
8656 8589 }
8657
8658 9829 void play_DmapMusic()
8659 {
8660 static char tfile[2048];
8661 static int32_t ttrack=0;
8662 9829 bool domidi=false;
8663
8664
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 8499 times.
9829 if(DMaps[currdmap].tmusic[0]!=0)
8665 {
8666
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8667
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8668
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8669 {
8670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8671 {
8672 zcmusic_stop(zcmusic);
8673 zcmusic_unload_file(zcmusic);
8674 zcmusic = NULL;
8675 }
8676
8677 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8678
8679
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8680 {
8681 86 zc_stop_midi();
8682 86 strcpy(tfile,DMaps[currdmap].tmusic);
8683 86 zcmusic_play(zcmusic, emusic_volume);
8684 86 int32_t temptracks=0;
8685 86 temptracks=zcmusic_get_tracks(zcmusic);
8686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8687 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8688 86 zcmusic_change_track(zcmusic,ttrack);
8689 86 }
8690 else
8691 {
8692 859 tfile[0] = 0;
8693 859 domidi=true;
8694 }
8695 945 }
8696 1330 }
8697 else
8698 {
8699 8499 domidi=true;
8700 }
8701
8702
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 9358 times.
9829 if(domidi)
8703 {
8704 9358 int32_t m=DMaps[currdmap].midi;
8705
8706
3/4
✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
9358 switch(m)
8707 {
8708 case 1:
8709 105 jukebox(ZC_MIDI_OVERWORLD);
8710 105 break;
8711
8712 case 2:
8713 10 jukebox(ZC_MIDI_DUNGEON);
8714 10 break;
8715
8716 case 3:
8717 jukebox(ZC_MIDI_LEVEL9);
8718 break;
8719
8720 default:
8721
3/4
✓ Branch 0 taken 8329 times.
✓ Branch 1 taken 914 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8329 times.
9243 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8722 8329 jukebox(m+MIDIOFFSET_DMAP);
8723 else
8724 914 music_stop();
8725 9243 }
8726 9358 }
8727 9829 }
8728
8729 9866 void playLevelMusic()
8730 {
8731 9866 int32_t m=tmpscr->screen_midi;
8732
8733
3/6
✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
9866 switch(m)
8734 {
8735 case -2:
8736 12 music_stop();
8737 12 break;
8738
8739 case -1:
8740 9813 play_DmapMusic();
8741 9813 break;
8742
8743 case 1:
8744 jukebox(ZC_MIDI_OVERWORLD);
8745 break;
8746
8747 case 2:
8748 jukebox(ZC_MIDI_DUNGEON);
8749 break;
8750
8751 case 3:
8752 jukebox(ZC_MIDI_LEVEL9);
8753 break;
8754
8755 default:
8756
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8757 41 jukebox(m+MIDIOFFSET_MAPSCR);
8758 else
8759 music_stop();
8760 41 }
8761 9866 }
8762
8763 1162 void master_volume(int32_t dv,int32_t mv)
8764 {
8765
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8766
8767
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8768
8769
6/6
✓ Branch 0 taken 1132 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 1160 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1130 times.
✓ Branch 5 taken 30 times.
1162 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8770 1162 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8771 1162 }
8772
8773 /*****************/
8774 /***** SFX *****/
8775 /*****************/
8776
8777 // array of voices, one for each sfx sample in the data file
8778 // 0+ = voice #
8779 // -1 = voice not allocated
8780 29 void Z_init_sound()
8781 {
8782
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<WAV_COUNT; i++)
8783 7424 sfx_voice[i]=-1;
8784
8785
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 29 times.
232 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8786 203 tunes[i].data = (MIDI*)mididata[i].dat;
8787
8788
2/2
✓ Branch 0 taken 7308 times.
✓ Branch 1 taken 29 times.
7337 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8789 7308 tunes[ZC_MIDI_COUNT+j].data=NULL;
8790
8791 29 master_volume(digi_volume,midi_volume);
8792 29 }
8793
8794 // returns number of voices currently allocated
8795 int32_t sfx_count()
8796 {
8797 int32_t c=0;
8798
8799 for(int32_t i=0; i<WAV_COUNT; i++)
8800 if(sfx_voice[i]!=-1)
8801 ++c;
8802
8803 return c;
8804 }
8805
8806 // clean up finished samples
8807 6480723 void sfx_cleanup()
8808 {
8809
2/2
✓ Branch 0 taken 1659065088 times.
✓ Branch 1 taken 6480723 times.
1665545811 for(int32_t i=0; i<WAV_COUNT; i++)
8810
3/4
✓ Branch 0 taken 560755 times.
✓ Branch 1 taken 1658504333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 560755 times.
1659625843 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8811 {
8812 560755 deallocate_voice(sfx_voice[i]);
8813 560755 sfx_voice[i]=-1;
8814 560755 }
8815 6480723 }
8816
8817 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8818 // if a voice is already allocated (and/or playing), then it just returns true
8819 // Returns true: voice is allocated
8820 // false: unsuccessful
8821 838762 bool sfx_init(int32_t index)
8822 {
8823 // check index
8824
3/4
✓ Branch 0 taken 620761 times.
✓ Branch 1 taken 218001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 620761 times.
838762 if(index<=0 || index>=WAV_COUNT)
8825 218001 return false;
8826
8827
2/2
✓ Branch 0 taken 59980 times.
✓ Branch 1 taken 560781 times.
620761 if(sfx_voice[index]==-1)
8828 {
8829
2/2
✓ Branch 0 taken 110294 times.
✓ Branch 1 taken 450487 times.
560781 if(sfxdat)
8830 {
8831
1/2
✓ Branch 0 taken 110294 times.
✗ Branch 1 not taken.
110294 if(index<Z35)
8832 {
8833 110294 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8834 110294 }
8835 else
8836 {
8837 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8838 }
8839 110294 }
8840 else
8841 {
8842 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8843 }
8844
8845 560781 voice_set_volume(sfx_voice[index], sfx_volume);
8846 560781 }
8847
8848 620761 return sfx_voice[index] != -1;
8849 838762 }
8850
8851 // plays an sfx sample
8852 732250 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8853 {
8854
2/2
✓ Branch 0 taken 550996 times.
✓ Branch 1 taken 181254 times.
732250 if(!sfx_init(index))
8855 181254 return;
8856
8857 550996 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8858 550996 voice_set_pan(sfx_voice[index],pan);
8859
8860 550996 int32_t pos = voice_get_position(sfx_voice[index]);
8861
8862
2/2
✓ Branch 0 taken 259936 times.
✓ Branch 1 taken 291060 times.
550996 if(restart) voice_set_position(sfx_voice[index],0);
8863
8864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550996 times.
550996 if(pos<=0)
8865 550996 voice_start(sfx_voice[index]);
8866
8867
3/4
✓ Branch 0 taken 291060 times.
✓ Branch 1 taken 259936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 291060 times.
550996 if (restart && replay_is_debug())
8868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291060 times.
291060 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8869 732250 }
8870
8871 // true if sfx is allocated
8872 32243 bool sfx_allocated(int32_t index)
8873 {
8874
3/4
✓ Branch 0 taken 9403 times.
✓ Branch 1 taken 22840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9403 times.
32243 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8875 }
8876
8877 // start it (in loop mode) if it's not already playing,
8878 // otherwise adjust it to play in loop mode -DD
8879 106512 void cont_sfx(int32_t index)
8880 {
8881
2/2
✓ Branch 0 taken 36747 times.
✓ Branch 1 taken 69765 times.
106512 if(!sfx_init(index))
8882 {
8883 36747 return;
8884 }
8885
8886
1/2
✓ Branch 0 taken 69765 times.
✗ Branch 1 not taken.
69765 if(voice_get_position(sfx_voice[index])<=0)
8887 {
8888 69765 voice_set_position(sfx_voice[index],0);
8889 69765 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8890 69765 voice_start(sfx_voice[index]);
8891 69765 }
8892 else
8893 {
8894 adjust_sfx(index, 128, true);
8895 }
8896 106512 }
8897
8898 // adjust parameters while playing
8899 3547 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8900 {
8901
5/6
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 1423 times.
✓ Branch 2 taken 2124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2110 times.
3547 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8902 3533 return;
8903
8904 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8905 14 voice_set_pan(sfx_voice[index],pan);
8906 3547 }
8907
8908 // pauses a voice
8909 1468 void pause_sfx(int32_t index)
8910 {
8911
3/6
✓ Branch 0 taken 1468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1468 times.
1468 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8912 voice_stop(sfx_voice[index]);
8913 1468 }
8914
8915 // resumes a voice
8916 637 void resume_sfx(int32_t index)
8917 {
8918
3/6
✓ Branch 0 taken 637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 637 times.
637 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8919 voice_start(sfx_voice[index]);
8920 637 }
8921
8922 // pauses all active voices
8923 244 void pause_all_sfx()
8924 {
8925
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 244 times.
62708 for(int32_t i=0; i<WAV_COUNT; i++)
8926
2/2
✓ Branch 0 taken 62462 times.
✓ Branch 1 taken 2 times.
62466 if(sfx_voice[i]!=-1)
8927 2 voice_stop(sfx_voice[i]);
8928 244 }
8929
8930 // resumes all paused voices
8931 230 void resume_all_sfx()
8932 {
8933
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 230 times.
59110 for(int32_t i=0; i<WAV_COUNT; i++)
8934
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(sfx_voice[i]!=-1)
8935 voice_start(sfx_voice[i]);
8936 230 }
8937
8938 // stops an sfx and deallocates the voice
8939 5203476 void stop_sfx(int32_t index)
8940 {
8941
3/4
✓ Branch 0 taken 5102116 times.
✓ Branch 1 taken 101360 times.
✓ Branch 2 taken 5102116 times.
✗ Branch 3 not taken.
5203476 if(index<=0 || index>=WAV_COUNT)
8942 101360 return;
8943
8944
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5102103 times.
5102116 if(sfx_voice[index]!=-1)
8945 {
8946 13 deallocate_voice(sfx_voice[index]);
8947 13 sfx_voice[index]=-1;
8948 13 }
8949 5203476 }
8950
8951 // Stops SFX played by Hero's item of the given family
8952 131169 void stop_item_sfx(int32_t family)
8953 {
8954 131169 int32_t id=current_item_id(family);
8955
8956
2/2
✓ Branch 0 taken 130841 times.
✓ Branch 1 taken 328 times.
131169 if(id<0)
8957 130841 return;
8958
8959 328 stop_sfx(itemsbuf[id].usesound);
8960 131169 }
8961
8962 1802 void kill_sfx()
8963 {
8964
2/2
✓ Branch 0 taken 461312 times.
✓ Branch 1 taken 1802 times.
463114 for(int32_t i=0; i<WAV_COUNT; i++)
8965
2/2
✓ Branch 0 taken 461299 times.
✓ Branch 1 taken 13 times.
461325 if(sfx_voice[i]!=-1)
8966 {
8967 13 deallocate_voice(sfx_voice[i]);
8968 13 sfx_voice[i]=-1;
8969 13 }
8970 1802 }
8971
8972 504198 int32_t pan(int32_t x)
8973 {
8974
1/4
✓ Branch 0 taken 504198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
504198 switch(pan_style)
8975 {
8976 case 0:
8977 return 128;
8978
8979 case 1:
8980 504198 return vbound((x>>1)+68,0,255);
8981
8982 case 2:
8983 return vbound(((x*3)>>2)+36,0,255);
8984 }
8985
8986 return vbound(x,0,255);
8987 504198 }
8988
8989 /*******************************/
8990 /******* Input Handlers ********/
8991 /*******************************/
8992
8993 16584516 bool joybtn(int32_t b)
8994 {
8995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16584516 times.
16584516 if(b == 0)
8996 return false;
8997
8998 16584516 return joy[joystick_index].button[b-1].b !=0;
8999 16584516 }
9000
9001 const char* joybtn_name(int32_t b)
9002 {
9003 if(b == 0)
9004 return "";
9005
9006 return joy[joystick_index].button[b-1].name;
9007 }
9008
9009 int32_t next_press_key();
9010
9011 int32_t next_press_btn()
9012 {
9013 clear_keybuf();
9014 /*bool b[joy[joystick_index].num_buttons+1];
9015
9016 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9017 b[i]=joybtn(i);*/
9018
9019 //first, we need to wait until they're pressing no buttons
9020 for(;;)
9021 {
9022 if(keypressed())
9023 {
9024 switch(readkey()>>8)
9025 {
9026 case KEY_ESC:
9027 return -1;
9028
9029 case KEY_SPACE:
9030 return 0;
9031 }
9032 }
9033
9034 poll_joystick();
9035 bool done = true;
9036
9037 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9038 {
9039 if(joybtn(i)) done = false;
9040 }
9041
9042 if(done) break;
9043 rest(1);
9044 }
9045
9046 //now, we need to wait for them to press any button
9047 for(;;)
9048 {
9049 if(keypressed())
9050 {
9051 switch(readkey()>>8)
9052 {
9053 case KEY_ESC:
9054 return -1;
9055
9056 case KEY_SPACE:
9057 return 0;
9058 }
9059 }
9060
9061 poll_joystick();
9062
9063 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9064 {
9065 if(joybtn(i)) return i;
9066 }
9067 rest(1);
9068 }
9069 }
9070
9071 134574253 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9072 {
9073
2/2
✓ Branch 0 taken 129784481 times.
✓ Branch 1 taken 4789772 times.
134574253 bool ret = btn && !flag;
9074
2/2
✓ Branch 0 taken 117573131 times.
✓ Branch 1 taken 17001122 times.
134574253 flag = rawbtn ? *rawbtn : btn;
9075
9076 134574253 return ret;
9077 }
9078 1337132 static bool rButtonPeek(bool btn, bool flag)
9079 {
9080
2/2
✓ Branch 0 taken 1249424 times.
✓ Branch 1 taken 87708 times.
1337132 if(!btn)
9081 {
9082 1249424 return false;
9083 }
9084
2/2
✓ Branch 0 taken 14956 times.
✓ Branch 1 taken 72752 times.
87708 else if(!flag)
9085 {
9086 14956 return true;
9087 }
9088
9089 72752 return false;
9090 1337132 }
9091
9092 // Updated only by keyboard/gamepad.
9093 // If in replay mode, this is set directly by the replay system.
9094 // This should never be read from directly - use control_state instead.
9095 bool raw_control_state[ZC_CONTROL_STATES];
9096
9097 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9098 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9099 // lasts until the next call to load_control_state.
9100 bool control_state[ZC_CONTROL_STATES];
9101 bool disable_control[ZC_CONTROL_STATES];
9102 bool drunk_toggle_state[11];
9103 bool disabledKeys[127];
9104 bool KeyInput[127];
9105 bool KeyPress[127];
9106
9107 bool key_current_frame[127];
9108 bool key_previous_frame[127];
9109
9110 static bool key_system[127];
9111 static bool key_system_previous[127];
9112 static bool key_system_press[127];
9113
9114 bool button_press[ZC_CONTROL_STATES];
9115 bool button_hold[ZC_CONTROL_STATES];
9116
9117 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9118 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9119 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9120 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9121 #define STICK_PRECISION 56 //define your own sensitivity
9122
9123 5438197 void load_control_state()
9124 {
9125 5438197 load_control_called_this_frame = true;
9126
9127
3/4
✓ Branch 0 taken 2566996 times.
✓ Branch 1 taken 2871201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2566996 times.
5438197 if (replay_get_version() >= 8 && replay_get_version() < 11)
9128 {
9129
2/2
✓ Branch 0 taken 46205928 times.
✓ Branch 1 taken 2566996 times.
48772924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9130 46205928 down_control_states[i] = raw_control_state[i];
9131 2566996 }
9132
9133
1/2
✓ Branch 0 taken 5438197 times.
✗ Branch 1 not taken.
5438197 if (!replay_is_replaying())
9134 {
9135 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9136 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9137 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9138 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9139 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9140 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9141 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9142 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9143 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9144 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9145 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9146 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9147 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9148 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9149
9150 if(num_joysticks != 0)
9151 {
9152 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9153 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9154 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9155 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9156 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9157 }
9158 else
9159 {
9160 raw_control_state[14] = false;
9161 raw_control_state[15] = false;
9162 raw_control_state[16] = false;
9163 raw_control_state[17] = false;
9164 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9165 }
9166 }
9167
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5438194 times.
5438197 if (replay_is_active())
9168 {
9169
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 4422979 times.
5438194 if (replay_get_version() < 3)
9170 1015215 replay_poll();
9171
3/4
✓ Branch 0 taken 4422979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2661604 times.
✓ Branch 3 taken 1761375 times.
4422979 else if (replay_is_replaying() && replay_get_version() < 6)
9172 1761375 replay_peek_input();
9173
4/6
✓ Branch 0 taken 2661604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2566996 times.
✓ Branch 3 taken 94608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2566996 times.
2661604 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9174 2566996 replay_peek_input();
9175
2/2
✓ Branch 0 taken 4320728 times.
✓ Branch 1 taken 1117466 times.
5438194 if (replay_get_version() == 8)
9176 1117466 update_keys();
9177 5438194 }
9178
9179 // Some test replay files were made before a serious input bug was fixed, so instead
9180 // of re-doing them or tossing them out, just check for that zplay version.
9181
3/4
✓ Branch 0 taken 5438191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 5316291 times.
5438197 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9182
2/2
✓ Branch 0 taken 97887438 times.
✓ Branch 1 taken 5438191 times.
103325629 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9183 {
9184 97887438 control_state[i] = raw_control_state[i];
9185
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 48400128 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
97887438 if (botched_input && !control_state[i])
9186 47077142 down_control_states[i] = false;
9187 97887438 }
9188
9189 5438191 button_press[0]=rButton(control_state[0],button_hold[0]);
9190 5438191 button_press[1]=rButton(control_state[1],button_hold[1]);
9191 5438191 button_press[2]=rButton(control_state[2],button_hold[2]);
9192 5438191 button_press[3]=rButton(control_state[3],button_hold[3]);
9193 5438191 button_press[4]=rButton(control_state[4],button_hold[4]);
9194 5438191 button_press[5]=rButton(control_state[5],button_hold[5]);
9195 5438191 button_press[6]=rButton(control_state[6],button_hold[6]);
9196 5438191 button_press[7]=rButton(control_state[7],button_hold[7]);
9197 5438191 button_press[8]=rButton(control_state[8],button_hold[8]);
9198 5438191 button_press[9]=rButton(control_state[9],button_hold[9]);
9199 5438191 button_press[10]=rButton(control_state[10],button_hold[10]);
9200 5438191 button_press[11]=rButton(control_state[11],button_hold[11]);
9201 5438191 button_press[12]=rButton(control_state[12],button_hold[12]);
9202 5438191 button_press[13]=rButton(control_state[13],button_hold[13]);
9203 5438191 button_press[14]=rButton(control_state[14],button_hold[14]);
9204 5438191 button_press[15]=rButton(control_state[15],button_hold[15]);
9205 5438191 button_press[16]=rButton(control_state[16],button_hold[16]);
9206 5438191 button_press[17]=rButton(control_state[17],button_hold[17]);
9207 5438191 }
9208
9209 // Returns true if any game key is pressed. This is needed because keypressed()
9210 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9211 28178162 bool zc_key_pressed()
9212 //may also need to use zc_getrawkey
9213 {
9214
7/10
✓ Branch 0 taken 22800161 times.
✓ Branch 1 taken 5378001 times.
✓ Branch 2 taken 5378001 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5378001 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4533401 times.
✓ Branch 7 taken 4533401 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1621032 times.
29799194 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9215
4/6
✓ Branch 0 taken 4533401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4533401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3418530 times.
✓ Branch 5 taken 3418530 times.
4533401 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9216
4/6
✓ Branch 0 taken 3418530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3418530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2176173 times.
✓ Branch 5 taken 2176173 times.
3418530 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9217
4/6
✓ Branch 0 taken 2176173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2176173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1838283 times.
✓ Branch 5 taken 1838283 times.
2176173 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9218
1/2
✓ Branch 0 taken 1838283 times.
✗ Branch 1 not taken.
1838283 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9219
3/4
✓ Branch 0 taken 1736661 times.
✓ Branch 1 taken 101622 times.
✓ Branch 2 taken 1736661 times.
✗ Branch 3 not taken.
1838283 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9220
3/4
✓ Branch 0 taken 1646160 times.
✓ Branch 1 taken 90501 times.
✓ Branch 2 taken 1646160 times.
✗ Branch 3 not taken.
1736661 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9221
3/4
✓ Branch 0 taken 1633476 times.
✓ Branch 1 taken 12684 times.
✓ Branch 2 taken 1633476 times.
✗ Branch 3 not taken.
1646160 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9222
3/4
✓ Branch 0 taken 1623117 times.
✓ Branch 1 taken 10359 times.
✓ Branch 2 taken 1623117 times.
✗ Branch 3 not taken.
1633476 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9223
3/4
✓ Branch 0 taken 1621864 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1621864 times.
✗ Branch 3 not taken.
1623117 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9224
3/4
✓ Branch 0 taken 1621821 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 1621821 times.
✗ Branch 3 not taken.
1621864 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9225
3/4
✓ Branch 0 taken 1621051 times.
✓ Branch 1 taken 770 times.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621821 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9226
2/4
✓ Branch 0 taken 1621051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621051 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9227
2/2
✓ Branch 0 taken 1621032 times.
✓ Branch 1 taken 19 times.
1621051 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9228 50489904 return true;
9229
9230 1621032 return false;
9231 6510614 }
9232
9233 108529366 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9234 {
9235 108529366 bool ret = false, drunkstate = false, rawret = false;
9236 108529366 bool* flag = &down_control_states[btn];
9237
2/7
✓ Branch 0 taken 102011933 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6517433 times.
108529366 switch(btn)
9238 {
9239 case btnF12:
9240 ret = zc_getkey(KEY_F12, ignoreDisable);
9241 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9242 eatEntirely = false;
9243 break;
9244 case btnF11:
9245 ret = zc_getkey(KEY_F11, ignoreDisable);
9246 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9247 eatEntirely = false;
9248 break;
9249 case btnF5:
9250 ret = zc_getkey(KEY_F5, ignoreDisable);
9251 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9252 eatEntirely = false;
9253 break;
9254 case btnQ:
9255 ret = zc_getkey(KEY_Q, ignoreDisable);
9256 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9257 eatEntirely = false;
9258 break;
9259 case btnI:
9260 ret = zc_getkey(KEY_I, ignoreDisable);
9261 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9262 eatEntirely = false;
9263 break;
9264 case btnM:
9265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6517433 times.
6517433 if(FFCore.kb_typing_mode) return false;
9266 6517433 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9267 6517433 eatEntirely = false;
9268 6517433 break;
9269 default: //control_state[] index
9270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102011933 times.
102011933 if(FFCore.kb_typing_mode) return false;
9271
5/6
✓ Branch 0 taken 101784203 times.
✓ Branch 1 taken 227730 times.
✓ Branch 2 taken 2257162 times.
✓ Branch 3 taken 99527041 times.
✓ Branch 4 taken 2257162 times.
✗ Branch 5 not taken.
102011933 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9272
2/2
✓ Branch 0 taken 5491613 times.
✓ Branch 1 taken 96520320 times.
102011933 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9273
4/4
✓ Branch 0 taken 91845546 times.
✓ Branch 1 taken 10166387 times.
✓ Branch 2 taken 1395 times.
✓ Branch 3 taken 10164992 times.
112178320 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9274 102011933 rawret = raw_control_state[btn];
9275 102011933 }
9276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
108529366 assert(flag);
9277
2/2
✓ Branch 0 taken 70505419 times.
✓ Branch 1 taken 38023947 times.
108529366 if(press)
9278 {
9279
2/2
✓ Branch 0 taken 1337132 times.
✓ Branch 1 taken 36686815 times.
38023947 if(peek)
9280 1337132 ret = rButtonPeek(ret, *flag);
9281
3/4
✓ Branch 0 taken 36686815 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17001122 times.
✓ Branch 3 taken 19685693 times.
36686815 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9282 17001122 else ret = rButton(ret, *flag, &rawret);
9283 38023947 }
9284
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108529366 if(eatEntirely && ret) control_state[btn] = false;
9285
3/4
✓ Branch 0 taken 82010678 times.
✓ Branch 1 taken 26518688 times.
✓ Branch 2 taken 82010678 times.
✗ Branch 3 not taken.
108529366 if(drunk && drunkstate) ret = !ret;
9286 108529366 return ret;
9287 108529366 }
9288
9289 5384201 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9290 {
9291 5384201 byte ret = 0;
9292
2/2
✓ Branch 0 taken 4045008 times.
✓ Branch 1 taken 1339193 times.
5384201 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9293
2/2
✓ Branch 0 taken 5383639 times.
✓ Branch 1 taken 562 times.
5384201 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9294
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9295
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9296
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9297
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9298
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9299
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9300 5384201 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9301 }
9302
9303 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9304 {
9305 1114 return intbtn&vals;
9306 }
9307
9308 1281348 bool Up()
9309 {
9310 1281348 return getInput(btnUp);
9311 }
9312 77421 bool Down()
9313 {
9314 77421 return getInput(btnDown);
9315 }
9316 167324 bool Left()
9317 {
9318 167324 return getInput(btnLeft);
9319 }
9320 188659 bool Right()
9321 {
9322 188659 return getInput(btnRight);
9323 }
9324 68115 bool cAbtn()
9325 {
9326 68115 return getInput(btnA);
9327 }
9328 1255212 bool cBbtn()
9329 {
9330 1255212 return getInput(btnB);
9331 }
9332 bool cSbtn()
9333 {
9334 return getInput(btnS);
9335 }
9336 29891 bool cLbtn()
9337 {
9338 29891 return getInput(btnL);
9339 }
9340 29891 bool cRbtn()
9341 {
9342 29891 return getInput(btnR);
9343 }
9344 bool cPbtn()
9345 {
9346 return getInput(btnP);
9347 }
9348 bool cEx1btn()
9349 {
9350 return getInput(btnEx1);
9351 }
9352 bool cEx2btn()
9353 {
9354 return getInput(btnEx2);
9355 }
9356 bool cEx3btn()
9357 {
9358 return getInput(btnEx3);
9359 }
9360 bool cEx4btn()
9361 {
9362 return getInput(btnEx4);
9363 }
9364 bool AxisUp()
9365 {
9366 return getInput(btnAxisUp);
9367 }
9368 bool AxisDown()
9369 {
9370 return getInput(btnAxisDown);
9371 }
9372 bool AxisLeft()
9373 {
9374 return getInput(btnAxisLeft);
9375 }
9376 bool AxisRight()
9377 {
9378 return getInput(btnAxisRight);
9379 }
9380
9381 bool cMbtn()
9382 {
9383 return getInput(btnM);
9384 }
9385 bool cF12()
9386 {
9387 return getInput(btnF12);
9388 }
9389 bool cF11()
9390 {
9391 return getInput(btnF11);
9392 }
9393 bool cF5()
9394 {
9395 return getInput(btnF5);
9396 }
9397 bool cQ()
9398 {
9399 return getInput(btnQ);
9400 }
9401 bool cI()
9402 {
9403 return getInput(btnI);
9404 }
9405
9406 112876 bool rUp()
9407 {
9408 112876 return getInput(btnUp, true);
9409 }
9410 112804 bool rDown()
9411 {
9412 112804 return getInput(btnDown, true);
9413 }
9414 112757 bool rLeft()
9415 {
9416 112757 return getInput(btnLeft, true);
9417 }
9418 112309 bool rRight()
9419 {
9420 112309 return getInput(btnRight, true);
9421 }
9422 2482 bool rAbtn()
9423 {
9424 2482 return getInput(btnA, true);
9425 }
9426 113491 bool rBbtn()
9427 {
9428 113491 return getInput(btnB, true);
9429 }
9430 5266505 bool rSbtn()
9431 {
9432 5266505 return getInput(btnS, true);
9433 }
9434 6510614 bool rMbtn()
9435 {
9436 6510614 return getInput(btnM, true);
9437 }
9438 112109 bool rLbtn()
9439 {
9440 112109 return getInput(btnL, true);
9441 }
9442 112106 bool rRbtn()
9443 {
9444 112106 return getInput(btnR, true);
9445 }
9446 5182404 bool rPbtn()
9447 {
9448 5182404 return getInput(btnP, true);
9449 }
9450 bool rEx1btn()
9451 {
9452 return getInput(btnEx1, true);
9453 }
9454 bool rEx2btn()
9455 {
9456 return getInput(btnEx2, true);
9457 }
9458 122985 bool rEx3btn()
9459 {
9460 122985 return getInput(btnEx3, true);
9461 }
9462 122985 bool rEx4btn()
9463 {
9464 122985 return getInput(btnEx4, true);
9465 }
9466 bool rAxisUp()
9467 {
9468 return getInput(btnAxisUp, true);
9469 }
9470 bool rAxisDown()
9471 {
9472 return getInput(btnAxisDown, true);
9473 }
9474 bool rAxisLeft()
9475 {
9476 return getInput(btnAxisLeft, true);
9477 }
9478 bool rAxisRight()
9479 {
9480 return getInput(btnAxisRight, true);
9481 }
9482
9483 bool rF11()
9484 {
9485 return getInput(btnF11, true);
9486 }
9487 bool rQ()
9488 {
9489 return getInput(btnQ, true);
9490 }
9491 bool rI()
9492 {
9493 return getInput(btnI, true);
9494 }
9495
9496 13317771 bool DrunkUp()
9497 {
9498 13317771 return getInput(btnUp, false, true);
9499 }
9500 12417217 bool DrunkDown()
9501 {
9502 12417217 return getInput(btnDown, false, true);
9503 }
9504 7866450 bool DrunkLeft()
9505 {
9506 7866450 return getInput(btnLeft, false, true);
9507 }
9508 6829749 bool DrunkRight()
9509 {
9510 6829749 return getInput(btnRight, false, true);
9511 }
9512 5759186 bool DrunkcAbtn()
9513 {
9514 5759186 return getInput(btnA, false, true);
9515 }
9516 5722928 bool DrunkcBbtn()
9517 {
9518 5722928 return getInput(btnB, false, true);
9519 }
9520 5152193 bool DrunkcEx1btn()
9521 {
9522 5152193 return getInput(btnEx1, false, true);
9523 }
9524 5152213 bool DrunkcEx2btn()
9525 {
9526 5152213 return getInput(btnEx2, false, true);
9527 }
9528 bool DrunkcSbtn()
9529 {
9530 return getInput(btnS, false, true);
9531 }
9532 bool DrunkcMbtn()
9533 {
9534 return getInput(btnM, false, true);
9535 }
9536 bool DrunkcLbtn()
9537 {
9538 return getInput(btnL, false, true);
9539 }
9540 bool DrunkcRbtn()
9541 {
9542 return getInput(btnR, false, true);
9543 }
9544 bool DrunkcPbtn()
9545 {
9546 return getInput(btnP, false, true);
9547 }
9548
9549 bool DrunkrUp()
9550 {
9551 return getInput(btnUp, true, true);
9552 }
9553 bool DrunkrDown()
9554 {
9555 return getInput(btnDown, true, true);
9556 }
9557 bool DrunkrLeft()
9558 {
9559 return getInput(btnLeft, true, true);
9560 }
9561 bool DrunkrRight()
9562 {
9563 return getInput(btnRight, true, true);
9564 }
9565 4315794 bool DrunkrAbtn()
9566 {
9567 4315794 return getInput(btnA, true, true);
9568 }
9569 4328323 bool DrunkrBbtn()
9570 {
9571 4328323 return getInput(btnB, true, true);
9572 }
9573 71669 bool DrunkrEx1btn()
9574 {
9575 71669 return getInput(btnEx1, true, true);
9576 }
9577 71662 bool DrunkrEx2btn()
9578 {
9579 71662 return getInput(btnEx2, true, true);
9580 }
9581 bool DrunkrEx3btn()
9582 {
9583 return getInput(btnEx3, true, true);
9584 }
9585 bool DrunkrEx4btn()
9586 {
9587 return getInput(btnEx4, true, true);
9588 }
9589 bool DrunkrSbtn()
9590 {
9591 return getInput(btnS, true, true);
9592 }
9593 bool DrunkrMbtn()
9594 {
9595 return getInput(btnM, true, true);
9596 }
9597 4832892 bool DrunkrLbtn()
9598 {
9599 4832892 return getInput(btnL, true, true);
9600 }
9601 4830254 bool DrunkrRbtn()
9602 {
9603 4830254 return getInput(btnR, true, true);
9604 }
9605 bool DrunkrPbtn()
9606 {
9607 return getInput(btnP, true, true);
9608 }
9609
9610 6819 void eat_buttons()
9611 {
9612 6819 getInput(btnA, true, false, true);
9613 6819 getInput(btnB, true, false, true);
9614 6819 getInput(btnS, true, false, true);
9615 6819 getInput(btnM, true, false, true);
9616 6819 getInput(btnL, true, false, true);
9617 6819 getInput(btnR, true, false, true);
9618 6819 getInput(btnP, true, false, true);
9619 6819 getInput(btnEx1, true, false, true);
9620 6819 getInput(btnEx2, true, false, true);
9621 6819 getInput(btnEx3, true, false, true);
9622 6819 getInput(btnEx4, true, false, true);
9623 6819 }
9624
9625 // Is true for the _first frame_ of a key press.
9626 // But! it is possible that a script manually sets the value of KeyPress,
9627 // in which case it will be restored to the "true" value based on `key_current_frame`
9628 // and `key_previous_frame` on the next frame.
9629 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9630 {
9631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9633 {
9634 case KEY_F7:
9635 case KEY_F8:
9636 case KEY_F9:
9637 return KeyPress[k];
9638
9639 default:
9640
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9641 }
9642 14 }
9643
9644 // Is true for _every frame_ a key is held down.
9645 // But! it is possible that a script manually sets the value of KeyInput,
9646 // in which case it will be restored to the "true" value based on `key_current_frame`
9647 // on the next frame.
9648 bool zc_getkey(int32_t k, bool ignoreDisable)
9649 {
9650 if(ignoreDisable) return KeyInput[k];
9651 switch(k)
9652 {
9653 case KEY_F7:
9654 case KEY_F8:
9655 case KEY_F9:
9656 return KeyInput[k];
9657
9658 default:
9659 return KeyInput[k] && !disabledKeys[k];
9660 }
9661 }
9662
9663 // Reads (and then clears) the current frame key state directly.
9664 // Scripts can also modify `key_current_frame`.
9665 125 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9666 {
9667
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
125 if(zc_getrawkey(k, ignoreDisable))
9668 {
9669 2 _key[k]=key[k]=key_current_frame[k]=0;
9670 2 return true;
9671 }
9672 123 _key[k]=key[k]=key_current_frame[k]=0;
9673 123 return false;
9674 125 }
9675
9676 // Reads the current frame key state directly.
9677 // Scripts can also modify `key_current_frame`.
9678 43497761 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9679 {
9680
2/2
✓ Branch 0 taken 36987119 times.
✓ Branch 1 taken 6510642 times.
43497761 if(ignoreDisable) return key_current_frame[k];
9681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 switch(k)
9682 {
9683 case KEY_F7:
9684 case KEY_F8:
9685 case KEY_F9:
9686 return key_current_frame[k];
9687
9688 default:
9689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 return key_current_frame[k] && !disabledKeys[k];
9690 }
9691 43497761 }
9692
9693 // Only used for a handful of keys, like tilde and Function keys.
9694 // This state is never read within the game.
9695 // It exists so that all keyboard input still functions during replay,
9696 // without inadvertently doing things like toggling throttling if the player
9697 // presses ~
9698 13021293 bool zc_get_system_key(int32_t k)
9699 {
9700 13021293 return key_system[k];
9701 }
9702
9703 // True for the _first_ frame of a key press.
9704 58595526 bool zc_read_system_key(int32_t k)
9705 {
9706 58595526 return key_system_press[k];
9707 }
9708
9709 826847978 bool is_system_key(int32_t k)
9710 {
9711
2/2
✓ Branch 0 taken 768252452 times.
✓ Branch 1 taken 58595526 times.
826847978 switch (k)
9712 {
9713 case KEY_BACKQUOTE:
9714 case KEY_CLOSEBRACE:
9715 case KEY_END:
9716 case KEY_HOME:
9717 case KEY_OPENBRACE:
9718 case KEY_PGDN:
9719 case KEY_PGUP:
9720 case KEY_TAB:
9721 case KEY_TILDE:
9722 58595526 return true;
9723 }
9724 768252452 return is_Fkey(k);
9725 826847978 }
9726
9727 6510614 void update_system_keys()
9728 {
9729
2/2
✓ Branch 0 taken 826847978 times.
✓ Branch 1 taken 6510614 times.
833358592 for (int32_t q = 0; q < 127; ++q)
9730 {
9731
2/2
✓ Branch 0 taken 136722894 times.
✓ Branch 1 taken 690125084 times.
826847978 if (!is_system_key(q))
9732 690125084 continue;
9733
9734 136722894 key_system[q] = key[q];
9735
1/2
✓ Branch 0 taken 136722894 times.
✗ Branch 1 not taken.
136722894 key_system_press[q] = key_system[q] && !key_system_previous[q];
9736 136722894 key_system_previous[q] = key_system[q];
9737 136722894 }
9738 6510614 }
9739
9740 7628080 void update_keys()
9741 {
9742
2/2
✓ Branch 0 taken 968766160 times.
✓ Branch 1 taken 7628080 times.
976394240 for (int32_t q = 0; q < 127; ++q)
9743 {
9744 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9745
1/2
✓ Branch 0 taken 968766160 times.
✗ Branch 1 not taken.
968766160 if (!replay_is_replaying())
9746 key_current_frame[q] = key[q];
9747
9748
2/2
✓ Branch 0 taken 961653306 times.
✓ Branch 1 taken 7112854 times.
968766160 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9749 968766160 KeyInput[q] = key_current_frame[q];
9750 968766160 key_previous_frame[q] = key_current_frame[q];
9751 968766160 }
9752 7628080 }
9753
9754 bool zc_disablekey(int32_t k, bool val)
9755 {
9756 switch(k)
9757 {
9758 case KEY_F7:
9759 case KEY_F8:
9760 case KEY_F9:
9761 return false;
9762
9763 default:
9764 disabledKeys[k] = val;
9765 return true;
9766 }
9767 }
9768
9769 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9770 {
9771 timer=timer;
9772 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9773 }
9774
9775 // these are here so that copy_dialog won't choke when compiling zelda
9776 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9777 {
9778 return D_O_K;
9779 }
9780
9781 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9782 {
9783 return D_O_K;
9784 }
9785
9786 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9787 {
9788 return D_O_K;
9789 }
9790
9791 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9792 {
9793 return D_O_K;
9794 }
9795
9796 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9797 {
9798 return D_O_K;
9799 }
9800
9801 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9802 {
9803 return D_O_K;
9804 }
9805
9806 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9807 {
9808 return D_O_K;
9809 }
9810
9811 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9812 {
9813 return D_O_K;
9814 }
9815
9816 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9817 {
9818 return D_O_K;
9819 }
9820
9821 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9822 {
9823 return D_O_K;
9824 }
9825
9826 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9827 {
9828 return D_O_K;
9829 }
9830
9831 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9832 {
9833 return D_O_K;
9834 }
9835
9836 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9837 {
9838 return D_O_K;
9839 }
9840
9841 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9842 {
9843 return D_O_K;
9844 }
9845
9846 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9847 {
9848 return D_O_K;
9849 }
9850
9851 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9852 {
9853 return D_O_K;
9854 }
9855
9856 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9857 {
9858 return D_O_K;
9859 }
9860
9861 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9862 {
9863 return D_O_K;
9864 }
9865
9866 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9867 {
9868 return D_O_K;
9869 }
9870
9871 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9872 {
9873 return D_O_K;
9874 }
9875
9876 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9877 {
9878 return D_O_K;
9879 }
9880
9881 /*** end of zc_sys.cc ***/
9882
9883